From 8a362c12a9f8891d45db95b2a7d900bd2dfbe9a1 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 9 Sep 2024 02:17:30 -0600 Subject: [PATCH] Update Inbox, add delay to move handler to allow for remote cache invalidation --- app/Util/ActivityPub/Inbox.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index 209ae4055..f4254528a 100644 --- a/app/Util/ActivityPub/Inbox.php +++ b/app/Util/ActivityPub/Inbox.php @@ -42,9 +42,11 @@ use App\Util\ActivityPub\Validator\MoveValidator; use App\Util\ActivityPub\Validator\UpdatePersonValidator; use Cache; use Illuminate\Support\Facades\Bus; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; use Purify; use Storage; +use Throwable; class Inbox { @@ -144,7 +146,8 @@ class Inbox case 'Move': if (MoveValidator::validate($this->payload) == false) { - \Log::info('[AP][INBOX][MOVE] VALIDATE_FAILURE '.json_encode($this->payload)); + Log::info('[AP][INBOX][MOVE] VALIDATE_FAILURE '.json_encode($this->payload)); + return; } $this->handleMoveActivity(); @@ -1366,7 +1369,8 @@ class Inbox ! Helpers::validateUrl($activity) || ! Helpers::validateUrl($target) ) { - \Log::info('[AP][INBOX][MOVE] validateUrl fail'); + Log::info('[AP][INBOX][MOVE] validateUrl fail'); + return; } @@ -1375,6 +1379,12 @@ class Inbox new MoveMigrateFollowersPipeline($target, $activity), new UnfollowLegacyAccountMovePipeline($target, $activity), new CleanupLegacyAccountMovePipeline($target, $activity), - ])->onQueue('move')->dispatch(); + ]) + ->catch(function (Throwable $e) { + Log::error($e); + }) + ->onQueue('move') + ->dispatch() + ->delay(now()->addMinutes(random_int(5, 9))); } }