]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/Notifier.php
Ensure author-link key has a value in Worker\Notifier
[friendica.git] / src / Worker / Notifier.php
index ec038d2313325ed5af55d083e4e59b1498ad95cb..1bcad1a73bfa756878eafcf7cbf21a30e8c053ef 100644 (file)
@@ -179,7 +179,7 @@ class Notifier
 
                        // Only deliver threaded replies (comment to a comment) to Diaspora
                        // when the original comment author does support the Diaspora protocol.
-                       if ($target_item['parent-uri'] != $target_item['thr-parent']) {
+                       if ($thr_parent['author-link'] && $target_item['parent-uri'] != $target_item['thr-parent']) {
                                $diaspora_delivery = Diaspora::isSupportedByContactUrl($thr_parent['author-link']);
                                Logger::info('Threaded comment', ['diaspora_delivery' => (int)$diaspora_delivery]);
                        }
@@ -475,7 +475,7 @@ class Notifier
                                                continue;
                                        }
 
-                                       if (self::skipDFRN($rr, $target_item, $parent, $thr_parent, $cmd)) {
+                                       if (self::skipDFRN($rr, $target_item, $parent, $thr_parent, $owner, $cmd)) {
                                                Logger::info('Contact can be delivered via AP, so skip delivery via legacy DFRN/Diaspora', ['id' => $target_id, 'url' => $rr['url']]);
                                                continue;
                                        }
@@ -530,7 +530,7 @@ class Notifier
                                continue;
                        }
 
-                       if (self::skipDFRN($contact, $target_item, $parent, $thr_parent, $cmd)) {
+                       if (self::skipDFRN($contact, $target_item, $parent, $thr_parent, $owner, $cmd)) {
                                Logger::info('Contact can be delivered via AP, so skip delivery via legacy DFRN/Diaspora', ['target' => $target_id, 'url' => $contact['url']]);
                                continue;
                        }
@@ -648,12 +648,13 @@ class Notifier
         * @param array  $item       The post
         * @param array  $parent     The parent
         * @param array  $thr_parent The thread parent
+        * @param array  $owner      Owner array
         * @param string $cmd        Notifier command
         * @return bool
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       private static function skipDFRN($contact, $item, $parent, $thr_parent, $cmd)
+       private static function skipDFRN($contact, $item, $parent, $thr_parent, $owner, $cmd)
        {
                if (empty($parent['network'])) {
                        return false;
@@ -689,6 +690,12 @@ class Notifier
                        return true;
                }
 
+               // For the time being we always deliver forum post via DFRN if possible
+               // This can be removed possible at the end of 2020 when hopefully most system can process AP forum posts
+               if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
+                       return false;
+               }
+
                // Skip DFRN when the item will be (forcefully) delivered via AP
                if (DI::config()->get('debug', 'total_ap_delivery') && ($contact['network'] == Protocol::DFRN) && !empty(APContact::getByURL($contact['url'], false))) {
                        return true;
@@ -779,6 +786,11 @@ class Notifier
 
                if ($target_item['origin']) {
                        $inboxes = ActivityPub\Transmitter::fetchTargetInboxes($target_item, $uid);
+
+                       if (in_array($target_item['private'], [Item::PUBLIC])) {
+                               $inboxes = ActivityPub\Transmitter::addRelayServerInboxes($inboxes);
+                       }
+
                        Logger::log('Origin item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . ' will be distributed.', Logger::DEBUG);
                } elseif (Item::isForumPost($target_item, $owner)) {
                        $inboxes = ActivityPub\Transmitter::fetchTargetInboxes($target_item, $uid, false, 0, true);