mirror of https://github.com/pixelfed/pixelfed
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Util\ActivityPub\Inbox;
|
|
|
|
use App\Jobs\ProfilePipeline\HandleUpdateActivity;
|
|
use App\Jobs\StatusPipeline\StatusRemoteUpdatePipeline;
|
|
use App\Models\Status;
|
|
use App\Util\ActivityPub\Helpers;
|
|
use App\Util\ActivityPub\Validator\UpdatePersonValidator;
|
|
|
|
trait HandlesUpdates
|
|
{
|
|
public function handleUpdateActivity(): void
|
|
{
|
|
$activity = $this->payload['object'];
|
|
|
|
if (! isset($activity['type'], $activity['id'])) {
|
|
return;
|
|
}
|
|
|
|
if (! Helpers::validateUrl($activity['id'])) {
|
|
return;
|
|
}
|
|
|
|
if ($activity['type'] === 'Note') {
|
|
$status = Status::whereObjectUrl($activity['id'])->first();
|
|
$actor = Helpers::profileFetch(Helpers::pluckval($this->payload['actor']));
|
|
|
|
if ($status && $actor && (int) $status->profile_id === (int) $actor->id) {
|
|
StatusRemoteUpdatePipeline::dispatch($activity);
|
|
}
|
|
} elseif ($activity['type'] === 'Person') {
|
|
if (UpdatePersonValidator::validate($this->payload)) {
|
|
HandleUpdateActivity::dispatch($this->payload)->onQueue('low');
|
|
}
|
|
}
|
|
}
|
|
}
|