Fix delete fanout

pull/6548/head
Daniel Supernault 2 months ago
parent 7be475cbb7
commit 92f469ff20
No known key found for this signature in database
GPG Key ID: 23740873EE6F76A1

@ -8,6 +8,7 @@ use App\User;
use App\Util\ActivityPub\HttpSignature;
use GuzzleHttp\Client;
use GuzzleHttp\Pool;
use GuzzleHttp\Psr7\Request;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use JsonException;
@ -69,6 +70,7 @@ class UserAccountDelete extends Command
);
$digest = base64_encode(hash('sha256', $payload, true));
$payloadLen = strlen($payload);
} catch (JsonException $e) {
$this->error("Failed to encode delete payload: {$e->getMessage()}");
@ -161,6 +163,7 @@ class UserAccountDelete extends Command
$client,
$payload,
$privateKey,
$payloadLen,
$keyId,
$digest,
$concurrency,
@ -191,6 +194,7 @@ class UserAccountDelete extends Command
digest: $digest,
urls: $pending,
payload: $payload,
payloadLen: $payloadLen,
concurrency: $concurrency,
verboseErrors: $this->option('verbose-errors')
);
@ -307,6 +311,7 @@ class UserAccountDelete extends Command
string $digest,
Collection $urls,
string $payload,
int $payloadLen,
int $concurrency,
bool $verboseErrors = false
): array {
@ -315,17 +320,12 @@ class UserAccountDelete extends Command
$httpFailed = [];
$retryable = collect();
$requests = function () use ($client, $urls, $privateKey, $keyId, $digest, $payload) {
foreach ($urls as $url) {
$requests = function () use ($urls, $privateKey, $keyId, $digest, $payload, $payloadLen) {
foreach ($urls as $key => $url) {
$headers = HttpSignature::signRawWithDigest($privateKey, $keyId, $url, $digest);
$headers['Content-Type'] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"';
yield function () use ($client, $url, $headers, $payload) {
return $client->postAsync($url, [
'headers' => $headers,
'body' => $payload,
]);
};
$headers['Content-Length'] = $payloadLen;
yield $key => new Request('POST', $url, $headers, $payload);
}
};

Loading…
Cancel
Save