From 12d3da5fdb8ba345ae3a91dc2e6920891736c677 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Fri, 22 Mar 2024 17:43:23 +0000 Subject: [PATCH] Webmentions were being saved with wrong model relationship Fix the process webmention job to use the correct model relationship, add an artisan command to update existing webmentions in the database to use the correct model relationship. --- .../UpdateWebmentionsRelationship.php | 36 +++++++++++++++++++ app/Jobs/ProcessWebMention.php | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 app/Console/Commands/UpdateWebmentionsRelationship.php diff --git a/app/Console/Commands/UpdateWebmentionsRelationship.php b/app/Console/Commands/UpdateWebmentionsRelationship.php new file mode 100644 index 00000000..f5bc1114 --- /dev/null +++ b/app/Console/Commands/UpdateWebmentionsRelationship.php @@ -0,0 +1,36 @@ +where('commentable_type', '=', 'App\Model\Note') + ->update(['commentable_type' => Note::class]); + + $this->info('All webmentions updated to relate to the correct note model class'); + } +} diff --git a/app/Jobs/ProcessWebMention.php b/app/Jobs/ProcessWebMention.php index 6aacf29d..457ab71d 100644 --- a/app/Jobs/ProcessWebMention.php +++ b/app/Jobs/ProcessWebMention.php @@ -92,7 +92,7 @@ class ProcessWebMention implements ShouldQueue $webmention->source = $this->source; $webmention->target = $this->note->longurl; $webmention->commentable_id = $this->note->id; - $webmention->commentable_type = 'App\Model\Note'; + $webmention->commentable_type = Note::class; $webmention->type = $type; $webmention->mf2 = json_encode($microformats); $webmention->save();