mirror of
https://github.com/YunoHost-Apps/pixelfed_ynh.git
synced 2024-09-03 20:06:04 +02:00
Update FederationController, improve inbox/sharedInbox delete handling
This commit is contained in:
parent
efd97d7fa4
commit
2180a2de3b
1 changed files with 36 additions and 26 deletions
|
@ -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']) &&
|
|
||||||
is_string($obj['id']) &&
|
|
||||||
is_string($obj['actor']) &&
|
|
||||||
is_string($obj['object']) &&
|
|
||||||
$obj['actor'] == $obj['object']
|
|
||||||
) {
|
|
||||||
if(Cache::get($lockKey) !== null) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
Cache::put($lockKey, 1, 43200);
|
|
||||||
usleep(5000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dispatch(new DeleteWorker($headers, $payload))->onQueue('delete');
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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']) &&
|
|
||||||
is_string($obj['actor']) &&
|
|
||||||
is_string($obj['object']) &&
|
|
||||||
$obj['actor'] == $obj['object']
|
|
||||||
) {
|
|
||||||
if(Cache::get($lockKey) !== null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Cache::put($lockKey, 1, 43200);
|
|
||||||
|
if($obj['object']['type'] === 'Tombstone') {
|
||||||
|
if(Status::whereObjectUrl($obj['object']['id'])->exists()) {
|
||||||
dispatch(new DeleteWorker($headers, $payload))->onQueue('delete');
|
dispatch(new DeleteWorker($headers, $payload))->onQueue('delete');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($obj['object']['type'] === 'Story') {
|
||||||
|
dispatch(new DeleteWorker($headers, $payload))->onQueue('delete');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 InboxWorker($headers, $payload))->onQueue('follow');
|
dispatch(new InboxWorker($headers, $payload))->onQueue('follow');
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue