1
0
Fork 0

Update AP Inbox

This commit is contained in:
Daniel Supernault 2022-12-24 05:35:35 -07:00
parent 36b88901f3
commit 31fc65fc74
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 50 additions and 54 deletions

View File

@ -69,16 +69,8 @@ class DeleteWorker implements ShouldQueue
)) ))
) { ) {
$actor = $payload['actor']; $actor = $payload['actor'];
$hash = strlen($actor) <= 48 ? if($this->verifySignature($headers, $payload) == true) {
'b:' . base64_encode($actor) : $actorDelete = Profile::whereRemoteUrl($actor)->exists();
'h:' . hash('sha256', $actor);
$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($actorDelete) {
if($this->verifySignature($headers, $payload) == true) { if($this->verifySignature($headers, $payload) == true) {
Cache::set($key, false); Cache::set($key, false);
@ -99,19 +91,23 @@ class DeleteWorker implements ShouldQueue
return 1; return 1;
} }
return 1;
} else {
return 1; return 1;
} }
} else {
$profile = null; $profile = null;
if($this->verifySignature($headers, $payload) == true) { if($this->verifySignature($headers, $payload) == true) {
ActivityHandler::dispatch($headers, $profile, $payload)->onQueue('inbox'); ActivityHandler::dispatch($headers, $profile, $payload)->onQueue('delete');
return 1; return 1;
} else { } else {
return 1; return 1;
} }
} }
}
protected function verifySignature($headers, $payload) protected function verifySignature($headers, $payload)
{ {
$body = $this->payload; $body = $this->payload;