Merge pull request #3979 from pixelfed/staging

Update FederationController, improve inbox/sharedInbox delete handling
This commit is contained in:
daniel 2022-12-20 02:56:06 -07:00 committed by GitHub
commit 1076668ca3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 26 deletions

View file

@ -63,6 +63,7 @@
- Update MediaS3GarbageCollector command, handle thumbnail deletion ([95bbcc38](https://github.com/pixelfed/pixelfed/commit/95bbcc38)) - 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 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 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/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4) ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4)

View file

@ -154,23 +154,27 @@ class FederationController extends Controller
} }
if(isset($obj['type']) && $obj['type'] === 'Delete') { if(isset($obj['type']) && $obj['type'] === 'Delete') {
$lockKey = 'pf:ap:del-lock:' . hash('sha256', $obj['id']); if(isset($obj['object']) && isset($obj['object']['type']) && isset($obj['object']['id'])) {
if( isset($obj['actor']) && if($obj['object']['type'] === 'Person') {
isset($obj['object']) && if(Profile::whereRemoteUrl($obj['object']['id'])->exists()) {
isset($obj['id']) && dispatch(new DeleteWorker($headers, $payload))->onQueue('delete');
is_string($obj['id']) && return;
is_string($obj['actor']) && }
is_string($obj['object']) && }
$obj['actor'] == $obj['object']
) { if($obj['object']['type'] === 'Tombstone') {
if(Cache::get($lockKey) !== null) { 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; 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'])) { } else if( isset($obj['type']) && in_array($obj['type'], ['Follow', 'Accept'])) {
dispatch(new InboxValidator($username, $headers, $payload))->onQueue('follow'); dispatch(new InboxValidator($username, $headers, $payload))->onQueue('follow');
} else { } else {
@ -208,21 +212,27 @@ class FederationController extends Controller
} }
if(isset($obj['type']) && $obj['type'] === 'Delete') { if(isset($obj['type']) && $obj['type'] === 'Delete') {
$lockKey = 'pf:ap:del-lock:' . hash('sha256', $obj['id']); if(isset($obj['object']) && isset($obj['object']['type']) && isset($obj['object']['id'])) {
if( isset($obj['actor']) && if($obj['object']['type'] === 'Person') {
isset($obj['object']) && if(Profile::whereRemoteUrl($obj['object']['id'])->exists()) {
isset($obj['id']) && dispatch(new DeleteWorker($headers, $payload))->onQueue('delete');
is_string($obj['id']) && return;
is_string($obj['actor']) && }
is_string($obj['object']) && }
$obj['actor'] == $obj['object']
) { if($obj['object']['type'] === 'Tombstone') {
if(Cache::get($lockKey) !== null) { 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; return;
} }
} }
Cache::put($lockKey, 1, 43200); return;
dispatch(new DeleteWorker($headers, $payload))->onQueue('delete');
} else if( isset($obj['type']) && in_array($obj['type'], ['Follow', 'Accept'])) { } else if( isset($obj['type']) && in_array($obj['type'], ['Follow', 'Accept'])) {
dispatch(new InboxWorker($headers, $payload))->onQueue('follow'); dispatch(new InboxWorker($headers, $payload))->onQueue('follow');
} else { } else {