]> git.mxchange.org Git - friendica.git/commitdiff
Inherit the receivers from the previous post
authorMichael <heluecht@pirati.ca>
Sat, 22 Sep 2018 04:39:04 +0000 (04:39 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 22 Sep 2018 04:39:04 +0000 (04:39 +0000)
src/Protocol/ActivityPub.php

index b27101aac8fb2f30a07f8b11ab93cce2310068d9..7205f5ab92551b3dbfe07fabbf037c740a241cc6 100644 (file)
@@ -122,7 +122,7 @@ class ActivityPub
                return $data;
        }
 
-       public static function fetchPermissionBlockFromConversation($item)
+       private static function fetchPermissionBlockFromConversation($item)
        {
                if (empty($item['thr-parent'])) {
                        return [];
@@ -216,10 +216,48 @@ class ActivityPub
                return $data;
        }
 
-       public static function fetchTargetInboxes($item, $uid)
+       private static function fetchTargetInboxesFromConversation($item)
        {
+               if (empty($item['thr-parent'])) {
+                       return [];
+               }
+
+               $condition = ['item-uri' => $item['thr-parent'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB];
+               $conversation = DBA::selectFirst('conversation', ['source'], $condition);
+               if (!DBA::isResult($conversation)) {
+                       return [];
+               }
+
+               $activity = json_decode($conversation['source'], true);
+
+               $actor = JsonLD::fetchElement($activity, 'actor', 'id');
+               $profile = ActivityPub::fetchprofile($actor);
+
                $inboxes = [];
 
+               $elements = ['to', 'cc', 'bto', 'bcc'];
+               foreach ($elements as $element) {
+                       if (empty($activity[$element])) {
+                               continue;
+                       }
+                       if (is_string($activity[$element])) {
+                               $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;
+                               }
+                       }
+               }
+               return $inboxes;
+       }
+
+       public static function fetchTargetInboxes($item, $uid)
+       {
+               $inboxes = self::fetchTargetInboxesFromConversation($item);
+
                $parents = Item::select(['author-link', 'owner-link'], ['parent' => $item['parent']]);
                while ($parent = Item::fetch($parents)) {
                        $profile = self::fetchprofile($parent['author-link']);