]> git.mxchange.org Git - friendica.git/commitdiff
Use the follower collection
authorMichael <heluecht@pirati.ca>
Sat, 22 Sep 2018 04:49:16 +0000 (04:49 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 22 Sep 2018 04:49:16 +0000 (04:49 +0000)
src/Protocol/ActivityPub.php

index 7205f5ab92551b3dbfe07fabbf037c740a241cc6..2c288feb5de626efd5bbae6e09c81b549cb3c9af 100644 (file)
@@ -216,7 +216,7 @@ class ActivityPub
                return $data;
        }
 
-       private static function fetchTargetInboxesFromConversation($item)
+       private static function fetchTargetInboxesFromConversation($item, $uid)
        {
                if (empty($item['thr-parent'])) {
                        return [];
@@ -244,10 +244,20 @@ class ActivityPub
                                $activity[$element] = [$activity[$element]];
                        }
                        foreach ($activity[$element] as $receiver) {
-                               $profile = self::fetchprofile($receiver);
-                               if (!empty($profile)) {
-                                       $target = defaults($profile, 'sharedinbox', $profile['inbox']);
-                                       $inboxes[$target] = $target;
+                               if ($receiver == $profile['followers']) {
+                                       $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']);
+                                               $inboxes[$contact] = $contact;
+                                       }
+                                       DBA::close($contacts);
+                               } else {
+                                       $profile = self::fetchprofile($receiver);
+                                       if (!empty($profile)) {
+                                               $target = defaults($profile, 'sharedinbox', $profile['inbox']);
+                                               $inboxes[$target] = $target;
+                                       }
                                }
                        }
                }
@@ -256,7 +266,7 @@ class ActivityPub
 
        public static function fetchTargetInboxes($item, $uid)
        {
-               $inboxes = self::fetchTargetInboxesFromConversation($item);
+               $inboxes = self::fetchTargetInboxesFromConversation($item, $uid);
 
                $parents = Item::select(['author-link', 'owner-link'], ['parent' => $item['parent']]);
                while ($parent = Item::fetch($parents)) {