From 2180a2de3b014dfcb7a16cfe66612f831910e973 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 20 Dec 2022 02:50:53 -0700 Subject: [PATCH 1/2] Update FederationController, improve inbox/sharedInbox delete handling --- app/Http/Controllers/FederationController.php | 62 +++++++++++-------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/app/Http/Controllers/FederationController.php b/app/Http/Controllers/FederationController.php index 245298d29..f498c7317 100644 --- a/app/Http/Controllers/FederationController.php +++ b/app/Http/Controllers/FederationController.php @@ -154,23 +154,27 @@ class FederationController extends Controller } if(isset($obj['type']) && $obj['type'] === 'Delete') { - $lockKey = 'pf:ap:del-lock:' . hash('sha256', $obj['id']); - if( isset($obj['actor']) && - isset($obj['object']) && - isset($obj['id']) && - is_string($obj['id']) && - is_string($obj['actor']) && - is_string($obj['object']) && - $obj['actor'] == $obj['object'] - ) { - if(Cache::get($lockKey) !== null) { + if(isset($obj['object']) && isset($obj['object']['type']) && isset($obj['object']['id'])) { + if($obj['object']['type'] === 'Person') { + if(Profile::whereRemoteUrl($obj['object']['id'])->exists()) { + dispatch(new DeleteWorker($headers, $payload))->onQueue('delete'); + return; + } + } + + if($obj['object']['type'] === 'Tombstone') { + if(Status::whereObjectUrl($obj['object']['id'])->exists()) { + dispatch(new DeleteWorker($headers, $payload))->onQueue('delete'); + return; + } + } + + if($obj['object']['type'] === 'Story') { + dispatch(new DeleteWorker($headers, $payload))->onQueue('delete'); return; - } else { - Cache::put($lockKey, 1, 43200); - usleep(5000); } } - dispatch(new DeleteWorker($headers, $payload))->onQueue('delete'); + return; } else if( isset($obj['type']) && in_array($obj['type'], ['Follow', 'Accept'])) { dispatch(new InboxValidator($username, $headers, $payload))->onQueue('follow'); } else { @@ -208,21 +212,27 @@ class FederationController extends Controller } if(isset($obj['type']) && $obj['type'] === 'Delete') { - $lockKey = 'pf:ap:del-lock:' . hash('sha256', $obj['id']); - if( isset($obj['actor']) && - isset($obj['object']) && - isset($obj['id']) && - is_string($obj['id']) && - is_string($obj['actor']) && - is_string($obj['object']) && - $obj['actor'] == $obj['object'] - ) { - if(Cache::get($lockKey) !== null) { + if(isset($obj['object']) && isset($obj['object']['type']) && isset($obj['object']['id'])) { + if($obj['object']['type'] === 'Person') { + if(Profile::whereRemoteUrl($obj['object']['id'])->exists()) { + dispatch(new DeleteWorker($headers, $payload))->onQueue('delete'); + return; + } + } + + if($obj['object']['type'] === 'Tombstone') { + if(Status::whereObjectUrl($obj['object']['id'])->exists()) { + dispatch(new DeleteWorker($headers, $payload))->onQueue('delete'); + return; + } + } + + if($obj['object']['type'] === 'Story') { + dispatch(new DeleteWorker($headers, $payload))->onQueue('delete'); return; } } - Cache::put($lockKey, 1, 43200); - dispatch(new DeleteWorker($headers, $payload))->onQueue('delete'); + return; } else if( isset($obj['type']) && in_array($obj['type'], ['Follow', 'Accept'])) { dispatch(new InboxWorker($headers, $payload))->onQueue('follow'); } else { From 7063b8033f3525d3ccb4429f699f25b2b865fc72 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 20 Dec 2022 02:55:17 -0700 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12c2028a7..7084245ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ - Update MediaS3GarbageCollector command, handle thumbnail deletion ([95bbcc38](https://github.com/pixelfed/pixelfed/commit/95bbcc38)) - Update StatusReplyPipeline, remove expensive reply count re-calculation query ([a2f8aad1](https://github.com/pixelfed/pixelfed/commit/a2f8aad1)) - Update CommentPipeline, remove expensive reply count re-calculation query ([b457a446](https://github.com/pixelfed/pixelfed/commit/b457a446)) +- Update FederationController, improve inbox/sharedInbox delete handling ([2180a2de](https://github.com/pixelfed/pixelfed/commit/2180a2de)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4)