- return true;
- } else {
- $item_id = $item['id'];
- }
- }
-
- $success = true;
-
- if ($cmd == Delivery::MAIL) {
- $data = ActivityPub\Transmitter::createActivityFromMail($item_id);
- if (!empty($data)) {
- $success = HTTPSignature::transmit($data, $inbox, $uid);
- }
- } elseif ($cmd == Delivery::SUGGESTION) {
- $success = ActivityPub\Transmitter::sendContactSuggestion($uid, $inbox, $item_id);
- } elseif ($cmd == Delivery::RELOCATION) {
- // @todo Implementation pending
- } elseif ($cmd == Delivery::POKE) {
- // Implementation not planned
- } elseif ($cmd == Delivery::REMOVAL) {
- $success = ActivityPub\Transmitter::sendProfileDeletion($uid, $inbox);
- } elseif ($cmd == Delivery::PROFILEUPDATE) {
- $success = ActivityPub\Transmitter::sendProfileUpdate($uid, $inbox);
- } else {
- $data = ActivityPub\Transmitter::createCachedActivityFromItem($item_id);
- if (!empty($data)) {
- $success = HTTPSignature::transmit($data, $inbox, $uid);
- if ($uri_id) {
- if ($success) {
- Post\Delivery::remove($uri_id, $inbox);
- } else {
- Post\Delivery::incrementFailed($uri_id, $inbox);
- }
- }
- }
- }
-
- self::setSuccess($receivers, $success);
-
- Logger::info('Delivered', ['uri-id' => $uri_id, 'uid' => $uid, 'item_id' => $item_id, 'cmd' => $cmd, 'inbox' => $inbox, 'success' => $success]);
-
- if ($success && in_array($cmd, [Delivery::POST])) {
- Post\DeliveryData::incrementQueueDone($uri_id, Post\DeliveryData::ACTIVITYPUB);
- }
-
- return $success;
- }
-
- private static function setSuccess(array $receivers, bool $success)
- {
- $gsid = null;
-
- foreach ($receivers as $receiver) {
- $contact = Contact::getById($receiver);
- if (empty($contact)) {
- continue;
- }
-
- $gsid = $gsid ?: $contact['gsid'];
-
- if ($success) {
- Contact::unmarkForArchival($contact);
- } else {
- Contact::markForArchival($contact);