mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update job queue, separate deletes into their own queue
This commit is contained in:
parent
3b071e56ac
commit
7f4213924f
3 changed files with 309 additions and 283 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Jobs\InboxPipeline\{
|
||||
DeleteWorker,
|
||||
InboxWorker,
|
||||
InboxValidator
|
||||
};
|
||||
|
@ -104,7 +105,13 @@ class FederationController extends Controller
|
|||
|
||||
$headers = $request->headers->all();
|
||||
$payload = $request->getContent();
|
||||
$obj = json_decode($payload, true, 8);
|
||||
|
||||
if(isset($obj['type']) && $obj['type'] === 'Delete') {
|
||||
dispatch(new DeleteWorker($headers, $payload))->onQueue('delete');
|
||||
} else {
|
||||
dispatch(new InboxValidator($username, $headers, $payload))->onQueue('high');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -115,7 +122,13 @@ class FederationController extends Controller
|
|||
|
||||
$headers = $request->headers->all();
|
||||
$payload = $request->getContent();
|
||||
$obj = json_decode($payload, true, 8);
|
||||
|
||||
if(isset($obj['type']) && $obj['type'] === 'Delete') {
|
||||
dispatch(new DeleteWorker($headers, $payload))->onQueue('delete');
|
||||
} else {
|
||||
dispatch(new InboxWorker($headers, $payload))->onQueue('high');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ class DeleteWorker implements ShouldQueue
|
|||
$payload = json_decode($this->payload, true, 8);
|
||||
|
||||
if(isset($payload['id'])) {
|
||||
$lockKey = hash('sha256', $payload['id']);
|
||||
$lockKey = 'pf:ap:del-lock:' . hash('sha256', $payload['id']);
|
||||
if(Cache::get($lockKey) !== null) {
|
||||
// Job processed already
|
||||
return 1;
|
||||
|
@ -116,6 +116,18 @@ class DeleteWorker implements ShouldQueue
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
$profile = null;
|
||||
|
||||
if($this->verifySignature($headers, $payload) == true) {
|
||||
(new Inbox($headers, $profile, $payload))->handle();
|
||||
return;
|
||||
} else if($this->blindKeyRotation($headers, $payload) == true) {
|
||||
(new Inbox($headers, $profile, $payload))->handle();
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected function verifySignature($headers, $payload)
|
||||
|
|
|
@ -82,6 +82,7 @@ return [
|
|||
'redis:feed' => 30,
|
||||
'redis:default' => 30,
|
||||
'redis:high' => 30,
|
||||
'redis:delete' => 30
|
||||
],
|
||||
|
||||
/*
|
||||
|
@ -165,7 +166,7 @@ return [
|
|||
'production' => [
|
||||
'supervisor-1' => [
|
||||
'connection' => 'redis',
|
||||
'queue' => ['high', 'default', 'feed'],
|
||||
'queue' => ['high', 'default', 'feed', 'delete'],
|
||||
'balance' => 'auto',
|
||||
'maxProcesses' => 20,
|
||||
'memory' => 128,
|
||||
|
@ -177,7 +178,7 @@ return [
|
|||
'local' => [
|
||||
'supervisor-1' => [
|
||||
'connection' => 'redis',
|
||||
'queue' => ['high', 'default', 'feed'],
|
||||
'queue' => ['high', 'default', 'feed', 'delete'],
|
||||
'balance' => 'auto',
|
||||
'maxProcesses' => 20,
|
||||
'memory' => 128,
|
||||
|
|
Loading…
Reference in a new issue