X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FNotifier.php;h=ad33c3245d4be9d33e1381cb9d1cb00b40851842;hb=514ec1be6df161df5cb48c033917ac2e94484f0f;hp=186422b6cc226e1f515d0ede607ea9255d1fcca3;hpb=51dbffd39697b794963eb6a9b87374e65a63f0aa;p=friendica.git diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 186422b6cc..ad33c3245d 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -20,6 +20,7 @@ use Friendica\Protocol\ActivityPub; use Friendica\Protocol\Diaspora; use Friendica\Protocol\OStatus; use Friendica\Protocol\Salmon; +use Friendica\Model\Conversation; require_once 'include/dba.php'; require_once 'include/items.php'; @@ -102,9 +103,9 @@ class Notifier $inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser(0); foreach ($inboxes as $inbox) { - logger('Account removal for user ' . $uid . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG); + logger('Account removal for user ' . $item_id . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG); Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true], - 'APDelivery', Delivery::REMOVAL, '', $inbox, $uid); + 'APDelivery', Delivery::REMOVAL, '', $inbox, $item_id); } return; @@ -176,6 +177,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); @@ -191,7 +194,7 @@ class Notifier // if $parent['wall'] == 1 we will already have the parent message in our array // and we will relay the whole lot. - $localhost = str_replace('www.','',$a->get_hostname()); + $localhost = str_replace('www.','',$a->getHostName()); if (strpos($localhost,':')) { $localhost = substr($localhost,0,strpos($localhost,':')); } @@ -422,27 +425,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 +509,41 @@ 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); + logger('Origin item ' . $item_id . ' with URL ' . $target_item['uri'] . ' will be distributed.', LOGGER_DEBUG); + } elseif (!DBA::exists('conversation', ['item-uri' => $target_item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB])) { + logger('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' is no AP post. It will not be distributed.', LOGGER_DEBUG); + return; + } else { + logger('Remote item ' . $item_id . ' with URL ' . $target_item['uri'] . ' will be distributed.', LOGGER_DEBUG); + } + + if ($parent['origin']) { + $parent_inboxes = ActivityPub\Transmitter::fetchTargetInboxes($parent, $uid); + $inboxes = array_merge($inboxes, $parent_inboxes); + } + + if (empty($inboxes)) { + logger('No inboxes found for item ' . $item_id . ' with URL ' . $target_item['uri'] . '. It will not be distributed.', LOGGER_DEBUG); + return; + } + + // 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']) ||