mirror of
https://github.com/friendica/friendica
synced 2024-11-12 22:22:54 +00:00
Simplifications for the experimental bulk delivery
This commit is contained in:
parent
f128c00ca5
commit
d5d2892f59
1 changed files with 14 additions and 23 deletions
|
@ -61,29 +61,15 @@ class APDelivery
|
||||||
$result = self::deliver($inbox);
|
$result = self::deliver($inbox);
|
||||||
$success = $result['success'];
|
$success = $result['success'];
|
||||||
$uri_ids = $result['uri_ids'];
|
$uri_ids = $result['uri_ids'];
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (empty($uri_ids)) {
|
|
||||||
$success = self::deliverToInbox($cmd, $item_id, $inbox, $uid, $receivers, $uri_id);
|
$success = self::deliverToInbox($cmd, $item_id, $inbox, $uid, $receivers, $uri_id);
|
||||||
|
$uri_ids = [$uri_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$success && !Worker::defer() && in_array($cmd, [Delivery::POST])) {
|
if (!$success && !Worker::defer() && in_array($cmd, [Delivery::POST])) {
|
||||||
if (!empty($uri_id)) {
|
foreach ($uri_ids as $uri_id) {
|
||||||
Post\Delivery::remove($uri_id, $inbox);
|
Post\Delivery::remove($uri_id, $inbox);
|
||||||
Post\DeliveryData::incrementQueueFailed($uri_id);
|
Post\DeliveryData::incrementQueueFailed($uri_id);
|
||||||
} elseif (!empty($uri_ids)) {
|
|
||||||
foreach ($uri_ids as $uri_id) {
|
|
||||||
Post\Delivery::remove($uri_id, $inbox);
|
|
||||||
Post\DeliveryData::incrementQueueFailed($uri_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} elseif ($success && in_array($cmd, [Delivery::POST])) {
|
|
||||||
if (!empty($uri_id)) {
|
|
||||||
Post\DeliveryData::incrementQueueDone($uri_id, Post\DeliveryData::ACTIVITYPUB);
|
|
||||||
} elseif (!empty($uri_ids)) {
|
|
||||||
foreach ($uri_ids as $uri_id) {
|
|
||||||
Post\DeliveryData::incrementQueueDone($uri_id, Post\DeliveryData::ACTIVITYPUB);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,13 +77,14 @@ class APDelivery
|
||||||
private static function deliver(string $inbox)
|
private static function deliver(string $inbox)
|
||||||
{
|
{
|
||||||
$uri_ids = [];
|
$uri_ids = [];
|
||||||
$success = true;
|
$posts = Post\Delivery::selectForInbox($inbox);
|
||||||
|
$success = empty($posts);
|
||||||
|
|
||||||
$posts = Post\Delivery::selectForInbox($inbox);
|
|
||||||
foreach ($posts as $post) {
|
foreach ($posts as $post) {
|
||||||
$uri_ids[] = $post['uri-id'];
|
if (self::deliverToInbox($post['command'], 0, $inbox, $post['uid'], [], $post['uri-id'])) {
|
||||||
if ($success) {
|
$success = true;
|
||||||
$success = self::deliverToInbox($post['command'], 0, $inbox, $post['uid'], [], $post['uri-id']);
|
} else {
|
||||||
|
$uri_ids[] = $post['uri-id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +106,7 @@ class APDelivery
|
||||||
if (empty($receivers)) {
|
if (empty($receivers)) {
|
||||||
$inboxes = ActivityPub\Transmitter::fetchTargetInboxes($parent, $uid, true);
|
$inboxes = ActivityPub\Transmitter::fetchTargetInboxes($parent, $uid, true);
|
||||||
$receivers = $inboxes[$inbox] ?? [];
|
$receivers = $inboxes[$inbox] ?? [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +141,10 @@ class APDelivery
|
||||||
|
|
||||||
Logger::info('Delivered', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $item_id, 'uri-id' => $uri_id, 'uid' => $uid, 'success' => $success]);
|
Logger::info('Delivered', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $item_id, 'uri-id' => $uri_id, 'uid' => $uid, 'success' => $success]);
|
||||||
|
|
||||||
|
if ($success && in_array($cmd, [Delivery::POST])) {
|
||||||
|
Post\DeliveryData::incrementQueueDone($uri_id, Post\DeliveryData::ACTIVITYPUB);
|
||||||
|
}
|
||||||
|
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue