- foreach ($terms as $term) {
- if ($term['type'] != TERM_MENTION) {
- continue;
- }
- $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']);
+ public static function fetchTargetInboxes($item, $uid)
+ {
+ $permissions = self::createPermissionBlockForItem($item);
+ if (empty($permissions)) {
+ return [];
+ }
+
+ $inboxes = [];
+
+ $item_profile = ActivityPub::fetchprofile($item['owner-link']);
+
+ $elements = ['to', 'cc', 'bto', 'bcc'];
+ foreach ($elements as $element) {
+ if (empty($permissions[$element])) {
+ continue;
+ }
+ foreach ($permissions[$element] as $receiver) {
+ if ($receiver == $item_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);