diff --git a/app/Util/ActivityPub/Helpers.php b/app/Util/ActivityPub/Helpers.php index 467298911..a70d828de 100644 --- a/app/Util/ActivityPub/Helpers.php +++ b/app/Util/ActivityPub/Helpers.php @@ -220,7 +220,7 @@ class Helpers { $id = (int) last(explode('/', $url)); return Status::findOrFail($id); } else { - $cached = Status::whereUri($url)->orWhere('url', $url)->first(); + $cached = Status::whereUri($url)->orWhere('object_url', $url)->first(); if($cached) { return $cached; } @@ -317,6 +317,7 @@ class Helpers { $status->profile_id = $profile->id; $status->url = isset($res['url']) ? $res['url'] : $url; $status->uri = isset($res['url']) ? $res['url'] : $url; + $status->object_url = isset($res['id']) ? $res['id'] : $url; $status->caption = strip_tags($res['content']); $status->rendered = Purify::clean($res['content']); $status->created_at = Carbon::parse($ts); diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index f7053e7bf..52205bb7d 100644 --- a/app/Util/ActivityPub/Inbox.php +++ b/app/Util/ActivityPub/Inbox.php @@ -326,7 +326,7 @@ class Inbox break; case 'Tombstone': - $status = Status::whereUri($id)->first(); + $status = Status::whereUri($id)->orWhere('object_url', $id)->first(); if(!$status) { return; } diff --git a/database/migrations/2019_09_09_032757_add_object_id_to_statuses_table.php b/database/migrations/2019_09_09_032757_add_object_id_to_statuses_table.php new file mode 100644 index 000000000..3cdf9e25a --- /dev/null +++ b/database/migrations/2019_09_09_032757_add_object_id_to_statuses_table.php @@ -0,0 +1,37 @@ +getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); + } + + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('statuses', function (Blueprint $table) { + $table->string('object_url')->nullable()->unique()->index(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('statuses', function (Blueprint $table) { + $table->dropColumn('object_url'); + }); + } +}