Update ProcessMovePipeline and Inbox

This commit is contained in:
Daniel Supernault 2024-09-10 20:21:05 -06:00
parent a46c295b13
commit dfdb7531f0
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
2 changed files with 0 additions and 25 deletions

View file

@ -11,7 +11,6 @@ use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Queue\Middleware\ThrottlesExceptionsWithRedis; use Illuminate\Queue\Middleware\ThrottlesExceptionsWithRedis;
use Illuminate\Queue\Middleware\WithoutOverlapping; use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Log;
class ProcessMovePipeline implements ShouldQueue class ProcessMovePipeline implements ShouldQueue
{ {
@ -78,19 +77,16 @@ class ProcessMovePipeline implements ShouldQueue
public function handle(): void public function handle(): void
{ {
if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') == false) { if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') == false) {
Log::info('pmp: AP not enabled');
throw new Exception('Activitypub not enabled'); throw new Exception('Activitypub not enabled');
} }
$validTarget = $this->checkTarget(); $validTarget = $this->checkTarget();
if (! $validTarget) { if (! $validTarget) {
Log::info('pmp: invalid target');
throw new Exception('Invalid target'); throw new Exception('Invalid target');
} }
$validActor = $this->checkActor(); $validActor = $this->checkActor();
if (! $validActor) { if (! $validActor) {
Log::info('pmp: invalid actor');
throw new Exception('Invalid actor'); throw new Exception('Invalid actor');
} }
@ -102,15 +98,11 @@ class ProcessMovePipeline implements ShouldQueue
$res = ActivityPubFetchService::fetchRequest($fetchTargetUrl, true); $res = ActivityPubFetchService::fetchRequest($fetchTargetUrl, true);
if (! $res || ! isset($res['alsoKnownAs'])) { if (! $res || ! isset($res['alsoKnownAs'])) {
Log::info('[AP][INBOX][MOVE] target_aka failure');
return false; return false;
} }
$targetRes = Helpers::profileFetch($this->target); $targetRes = Helpers::profileFetch($this->target);
if (! $targetRes) { if (! $targetRes) {
Log::info('[AP][INBOX][MOVE] target fetch failure');
return false; return false;
} }
@ -124,9 +116,6 @@ class ProcessMovePipeline implements ShouldQueue
}); });
$res = in_array($this->activity, $map); $res = in_array($this->activity, $map);
$debugMessage = $res ? '[AP][INBOX][MOVE] aka target is valid' : '[AP][INBOX][MOVE] aka target is invalid';
Log::info($debugMessage);
return $res; return $res;
} }
@ -140,29 +129,17 @@ class ProcessMovePipeline implements ShouldQueue
$res = ActivityPubFetchService::fetchRequest($fetchActivityUrl, true); $res = ActivityPubFetchService::fetchRequest($fetchActivityUrl, true);
if (! $res || ! isset($res['movedTo']) || empty($res['movedTo'])) { if (! $res || ! isset($res['movedTo']) || empty($res['movedTo'])) {
Log::info('[AP][INBOX][MOVE] actor_movedTo failure');
$payload = json_encode($res, JSON_PRETTY_PRINT);
Log::info($payload);
return false; return false;
} }
$actorRes = Helpers::profileFetch($this->activity); $actorRes = Helpers::profileFetch($this->activity);
if (! $actorRes) { if (! $actorRes) {
Log::info('[AP][INBOX][MOVE] actor fetch failure');
return false; return false;
} }
if (is_string($res['movedTo'])) { if (is_string($res['movedTo'])) {
$match = $this->lowerTrim($res['movedTo']) === $this->lowerTrim($this->target); $match = $this->lowerTrim($res['movedTo']) === $this->lowerTrim($this->target);
if (! $match) { if (! $match) {
$msg = json_encode([
'movedTo' => $res['movedTo'],
'target' => $this->target,
]);
Log::info('[AP][INBOX][MOVE] invalid actor match.'.$msg);
return false; return false;
} }

View file

@ -1369,8 +1369,6 @@ class Inbox
! Helpers::validateUrl($activity) || ! Helpers::validateUrl($activity) ||
! Helpers::validateUrl($target) ! Helpers::validateUrl($target)
) { ) {
Log::info('[AP][INBOX][MOVE] validateUrl fail');
return; return;
} }