Merge pull request #1347 from jonnybarnes/1321-fix-webmentions

Webmentions were being saved with wrong model relationship
This commit is contained in:
Jonny Barnes 2024-03-22 17:48:53 +00:00 committed by GitHub
commit 1cb1eac8fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 1 deletions

View file

@ -0,0 +1,36 @@
<?php
namespace App\Console\Commands;
use App\Models\Note;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class UpdateWebmentionsRelationship extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'webmentions:update-model-relationship';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update webmentions to relate to the correct note model class';
/**
* Execute the console command.
*/
public function handle()
{
DB::table('webmentions')
->where('commentable_type', '=', 'App\Model\Note')
->update(['commentable_type' => Note::class]);
$this->info('All webmentions updated to relate to the correct note model class');
}
}

View file

@ -92,7 +92,7 @@ class ProcessWebMention implements ShouldQueue
$webmention->source = $this->source; $webmention->source = $this->source;
$webmention->target = $this->note->longurl; $webmention->target = $this->note->longurl;
$webmention->commentable_id = $this->note->id; $webmention->commentable_id = $this->note->id;
$webmention->commentable_type = 'App\Model\Note'; $webmention->commentable_type = Note::class;
$webmention->type = $type; $webmention->type = $type;
$webmention->mf2 = json_encode($microformats); $webmention->mf2 = json_encode($microformats);
$webmention->save(); $webmention->save();