]> git.mxchange.org Git - friendica.git/commitdiff
Deliver everything to all receivers in the thread
authorMichael <heluecht@pirati.ca>
Fri, 21 Sep 2018 12:06:36 +0000 (12:06 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 21 Sep 2018 12:06:36 +0000 (12:06 +0000)
src/Protocol/ActivityPub.php
src/Worker/Notifier.php

index edc3de3f3b4e3b7dadaf04665ee0bba366b3e5bf..ad4308cbb6ee73ac63cb4aaaaad51ddfefc7cfc3 100644 (file)
@@ -46,13 +46,13 @@ use Friendica\Util\LDSignature;
  * - Object Types: Person, Tombstome
  *
  * Transmitter:
- * - Activities: Like, Dislike, Update, Delete
- * - Object Tyoes: Article, Announce, Person, Tombstone
+ * - Activities: Like, Dislike, Update, Delete, Announce
+ * - Object Tyoes: Article, Person, Tombstone
  *
  * General:
- * - Message distribution
- * - Endpoints: Outbox, Object, Follower, Following
+ * - Endpoints: Outbox, Follower, Following
  * - General cleanup
+ * - Queueing unsucessful deliveries
  */
 class ActivityPub
 {
@@ -172,13 +172,28 @@ class ActivityPub
                return $data;
        }
 
-       public static function fetchTargetInboxes($item)
+       public static function fetchTargetInboxes($item, $uid)
        {
                $inboxes = [];
 
+               $parents = Item::select(['author-link', 'owner-link'], ['parent' => $item['parent']]);
+               while ($parent = Item::fetch($parents)) {
+                       $profile = self::fetchprofile($parent['author-link']);
+                       if (!empty($profile)) {
+                               $target = defaults($profile, 'sharedinbox', $profile['inbox']);
+                               $inboxes[$target] = $target;
+                       }
+                       $profile = self::fetchprofile($parent['owner-link']);
+                       if (!empty($profile)) {
+                               $target = defaults($profile, 'sharedinbox', $profile['inbox']);
+                               $inboxes[$target] = $target;
+                       }
+               }
+               DBA::close($parents);
+
                $terms = Term::tagArrayFromItemId($item['id']);
                if (!$item['private']) {
-                       $contacts = DBA::select('contact', ['notify', 'batch'], ['uid' => $item['uid'],
+                       $contacts = DBA::select('contact', ['notify', 'batch'], ['uid' => $uid,
                                        'rel' => [Contact::FOLLOWER, Contact::FRIEND], 'network' => Protocol::ACTIVITYPUB]);
                        while ($contact = DBA::fetch($contacts)) {
                                $contact = defaults($contact, 'batch', $contact['notify']);
@@ -205,7 +220,7 @@ class ActivityPub
                                if ($term['type'] != TERM_MENTION) {
                                        continue;
                                }
-                               $cid = Contact::getIdForURL($term['url'], $item['uid']);
+                               $cid = Contact::getIdForURL($term['url'], $uid);
                                if (!empty($cid) && in_array($cid, $receiver_list)) {
                                        $contact = DBA::selectFirst('contact', ['url'], ['id' => $cid, 'network' => Protocol::ACTIVITYPUB]);
                                        $profile = self::fetchprofile($contact['url']);
index 3e73b5b5ed19bc86a6712244057685516ed1153c..286bcd03ee9be2e6afea22287fea902e11fe059c 100644 (file)
@@ -416,21 +416,13 @@ class Notifier
 
                $inboxes = [];
 
-               if ($followup) {
-                       $profile = ActivityPub::fetchprofile($parent['author-link']);
-                       if (!empty($profile)) {
-                               $target = defaults($profile, 'sharedinbox', $profile['inbox']);
-                               $inboxes[$target] = $target;
-                       }
-               } else {
-                       if ($target_item['origin']) {
-                               $inboxes = ActivityPub::fetchTargetInboxes($target_item);
-                       }
+               if ($target_item['origin']) {
+                       $inboxes = ActivityPub::fetchTargetInboxes($target_item, $uid);
+               }
 
-                       if ($parent['origin']) {
-                               $parent_inboxes = ActivityPub::fetchTargetInboxes($parent);
-                               $inboxes = array_merge($inboxes, $parent_inboxes);
-                       }
+               if ($parent['origin']) {
+                       $parent_inboxes = ActivityPub::fetchTargetInboxes($parent, $uid);
+                       $inboxes = array_merge($inboxes, $parent_inboxes);
                }
 
                foreach ($inboxes as $inbox) {