]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/Notifier.php
Fix notices in include/enotify
[friendica.git] / src / Worker / Notifier.php
index d40d9068fade2c5aef46e465dd80b6363a92a06a..ad33c3245d4be9d33e1381cb9d1cb00b40851842 100644 (file)
@@ -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;
@@ -193,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,':'));
                        }
@@ -514,6 +515,12 @@ class Notifier
 
                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']) {
@@ -521,6 +528,11 @@ class Notifier
                        $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);