From 6d6a033a54e4a058abff3ebf09065d5fc48e8820 Mon Sep 17 00:00:00 2001 From: Daniel Supernault <877217+dansup@users.noreply.github.com> Date: Wed, 31 Aug 2022 20:57:20 -0600 Subject: [PATCH] Update DeleteWorker, remove cache lock --- app/Jobs/InboxPipeline/DeleteWorker.php | 50 +++++++++++-------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/app/Jobs/InboxPipeline/DeleteWorker.php b/app/Jobs/InboxPipeline/DeleteWorker.php index a55623e63..5639f9752 100644 --- a/app/Jobs/InboxPipeline/DeleteWorker.php +++ b/app/Jobs/InboxPipeline/DeleteWorker.php @@ -72,39 +72,31 @@ class DeleteWorker implements ShouldQueue 'b:' . base64_encode($actor) : 'h:' . hash('sha256', $actor); - $lockKey = 'ap:inbox:actor-delete-exists:lock:' . $hash; - Cache::lock($lockKey, 30)->block(15, function () use( - $headers, - $payload, - $actor, - $hash - ) { - $key = 'ap:inbox:actor-delete-exists:' . $hash; - $actorDelete = Cache::remember($key, now()->addMinutes(15), function() use($actor) { - return Profile::whereRemoteUrl($actor) - ->whereNotNull('domain') - ->exists(); - }); - if($actorDelete) { - if($this->verifySignature($headers, $payload) == true) { - Cache::set($key, false); - $profile = Profile::whereNotNull('domain') - ->whereNull('status') - ->whereRemoteUrl($actor) - ->first(); - if($profile) { - DeleteRemoteProfilePipeline::dispatch($profile)->onQueue('delete'); - } - return 1; - } else { - // Signature verification failed, exit. - return 1; + $key = 'ap:inbox:actor-delete-exists:' . $hash; + $actorDelete = Cache::remember($key, now()->addMinutes(15), function() use($actor) { + return Profile::whereRemoteUrl($actor) + ->whereNotNull('domain') + ->exists(); + }); + if($actorDelete) { + if($this->verifySignature($headers, $payload) == true) { + Cache::set($key, false); + $profile = Profile::whereNotNull('domain') + ->whereNull('status') + ->whereRemoteUrl($actor) + ->first(); + if($profile) { + DeleteRemoteProfilePipeline::dispatch($profile)->onQueue('delete'); } + return 1; } else { - // Remote user doesn't exist, exit early. + // Signature verification failed, exit. return 1; } - }); + } else { + // Remote user doesn't exist, exit early. + return 1; + } return 1; }