From f69c80b9e20d145e98d43ea8b428ae39775b4562 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 6 Oct 2018 03:16:38 +0000 Subject: [PATCH] AP delivery is relocated to the top of the notifier --- src/Worker/Notifier.php | 47 +++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 186422b6c..d40d9068f 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -176,6 +176,8 @@ class Notifier if (!in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION, Delivery::RELOCATION])) { $parent = $items[0]; + self::activityPubDelivery($a, $cmd, $item_id, $uid, $target_item, $parent); + $fields = ['network', 'author-id', 'owner-id']; $condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]]; $thr_parent = Item::selectFirst($fields, $condition); @@ -422,27 +424,6 @@ class Notifier } } - $inboxes = []; - - if ($target_item['origin']) { - $inboxes = ActivityPub\Transmitter::fetchTargetInboxes($target_item, $uid); - } - - if ($parent['origin']) { - $parent_inboxes = ActivityPub\Transmitter::fetchTargetInboxes($parent, $uid); - $inboxes = array_merge($inboxes, $parent_inboxes); - } - - // Fill the item cache - ActivityPub\Transmitter::createCachedActivityFromItem($item_id); - - foreach ($inboxes as $inbox) { - logger('Deliver ' . $item_id .' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG); - - Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], - 'APDelivery', $cmd, $item_id, $inbox, $uid); - } - // send salmon slaps to mentioned remote tags (@foo@example.com) in OStatus posts // They are especially used for notifications to OStatus users that don't follow us. if (!Config::get('system', 'dfrn_only') && count($url_recipients) && ($public_message || $push_notify) && $normal_mode) { @@ -527,6 +508,30 @@ class Notifier return; } + private static function activityPubDelivery($a, $cmd, $item_id, $uid, $target_item, $parent) + { + $inboxes = []; + + if ($target_item['origin']) { + $inboxes = ActivityPub\Transmitter::fetchTargetInboxes($target_item, $uid); + } + + if ($parent['origin']) { + $parent_inboxes = ActivityPub\Transmitter::fetchTargetInboxes($parent, $uid); + $inboxes = array_merge($inboxes, $parent_inboxes); + } + + // Fill the item cache + ActivityPub\Transmitter::createCachedActivityFromItem($item_id); + + foreach ($inboxes as $inbox) { + logger('Deliver ' . $item_id .' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG); + + Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], + 'APDelivery', $cmd, $item_id, $inbox, $uid); + } + } + private static function isForumPost($item, $owner) { if (($item['author-id'] == $item['owner-id']) || ($owner['id'] == $item['contact-id']) ||