From: Michael Date: Sat, 22 Sep 2018 04:39:04 +0000 (+0000) Subject: Inherit the receivers from the previous post X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b7744ae3eb07f7e8b9bd4e68d331ce053ffb689c;p=friendica.git Inherit the receivers from the previous post --- diff --git a/src/Protocol/ActivityPub.php b/src/Protocol/ActivityPub.php index b27101aac8..7205f5ab92 100644 --- a/src/Protocol/ActivityPub.php +++ b/src/Protocol/ActivityPub.php @@ -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']);