Update ProcessMovePipeline

This commit is contained in:
Daniel Supernault 2024-09-08 23:14:49 -06:00
parent 6615408023
commit 5ad25759cc
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1

View file

@ -3,12 +3,13 @@
namespace App\Jobs\MovePipeline; namespace App\Jobs\MovePipeline;
use App\Services\ActivityPubFetchService; use App\Services\ActivityPubFetchService;
use DateTime;
use Exception; use Exception;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable; use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Queue\Middleware\ThrottlesExceptions; use Illuminate\Queue\Middleware\ThrottlesExceptions;
use Illuminate\Queue\Middleware\WithoutOverlapping; use Illuminate\Queue\Middleware\WithoutOverlapping;
use DateTime; use Illuminate\Support\Arr;
use Log; use Log;
class ProcessMovePipeline implements ShouldQueue class ProcessMovePipeline implements ShouldQueue
@ -88,12 +89,14 @@ class ProcessMovePipeline implements ShouldQueue
if (! $res || ! isset($res['alsoKnownAs'])) { if (! $res || ! isset($res['alsoKnownAs'])) {
Log::info('[AP][INBOX][MOVE] target_aka failure'); Log::info('[AP][INBOX][MOVE] target_aka failure');
return false; return false;
} }
$res = Helpers::profileFetch($this->target); $res = Helpers::profileFetch($this->target);
if (! $res) { if (! $res) {
Log::info('[AP][INBOX][MOVE] target fetch failure'); Log::info('[AP][INBOX][MOVE] target fetch failure');
return false; return false;
} }
@ -102,9 +105,16 @@ class ProcessMovePipeline implements ShouldQueue
} }
if (is_array($res['alsoKnownAs'])) { if (is_array($res['alsoKnownAs'])) {
$map = array_map(self::lowerTrim(), $res['alsoKnownAs']); $map = Arr::map($res['alsoKnownAs'], function ($value, $key) {
return trim(strtolower($value));
});
return in_array($this->actor, $map); $res = in_array($this->actor, $map);
$debugMessage = $res ? '[AP][INBOX][MOVE] aka target is valid' : '[AP][INBOX][MOVE] aka target is invalid';
Log::info($debugMessage);
return $res;
} }
return false; return false;
@ -116,12 +126,14 @@ class ProcessMovePipeline implements ShouldQueue
if (! $res || ! isset($res['movedTo'])) { if (! $res || ! isset($res['movedTo'])) {
Log::info('[AP][INBOX][MOVE] actor_movedTo failure'); Log::info('[AP][INBOX][MOVE] actor_movedTo failure');
return false; return false;
} }
$res = Helpers::profileFetch($this->actor); $res = Helpers::profileFetch($this->actor);
if (! $res) { if (! $res) {
Log::info('[AP][INBOX][MOVE] actor fetch failure'); Log::info('[AP][INBOX][MOVE] actor fetch failure');
return false; return false;
} }