mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
Update FederationController
This commit is contained in:
parent
3172cb59cd
commit
cb2392f351
2 changed files with 34 additions and 9 deletions
|
@ -121,6 +121,23 @@ class FederationController extends Controller
|
|||
$obj = json_decode($payload, true, 8);
|
||||
|
||||
if(isset($obj['type']) && $obj['type'] === 'Delete') {
|
||||
if(!isset($obj['id'])) {
|
||||
return;
|
||||
}
|
||||
$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) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Cache::put($lockKey, 1, 3600);
|
||||
dispatch(new DeleteWorker($headers, $payload))->onQueue('delete');
|
||||
} else {
|
||||
dispatch(new InboxValidator($username, $headers, $payload))->onQueue('high');
|
||||
|
@ -138,6 +155,23 @@ class FederationController extends Controller
|
|||
$obj = json_decode($payload, true, 8);
|
||||
|
||||
if(isset($obj['type']) && $obj['type'] === 'Delete') {
|
||||
if(!isset($obj['id'])) {
|
||||
return;
|
||||
}
|
||||
$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) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Cache::put($lockKey, 1, 3600);
|
||||
dispatch(new DeleteWorker($headers, $payload))->onQueue('delete');
|
||||
} else {
|
||||
dispatch(new InboxWorker($headers, $payload))->onQueue('high');
|
||||
|
|
|
@ -49,15 +49,6 @@ class DeleteWorker implements ShouldQueue
|
|||
$headers = $this->headers;
|
||||
$payload = json_decode($this->payload, true, 8);
|
||||
|
||||
if(isset($payload['id'])) {
|
||||
$lockKey = 'pf:ap:del-lock:' . hash('sha256', $payload['id']);
|
||||
if(Cache::get($lockKey) !== null) {
|
||||
// Job processed already
|
||||
return 1;
|
||||
}
|
||||
Cache::put($lockKey, 1, 300);
|
||||
}
|
||||
|
||||
if(!isset($headers['signature']) || !isset($headers['date'])) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue