]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/ActivityPub/Transmitter.php
Merge pull request #13724 from Raroun/Fix-for-Issue-#13637---Photo-caption-prevents...
[friendica.git] / src / Protocol / ActivityPub / Transmitter.php
index 9d0d998f9d6dd56df96573126210823fc0796db7..c15ee42dfe33248a31556562d0153940622b7e47 100644 (file)
@@ -368,7 +368,8 @@ class Transmitter
                        $data['outbox']    = DI::baseUrl() . '/outbox/' . $owner['nick'];
                        $data['featured']  = DI::baseUrl() . '/featured/' . $owner['nick'];
                } else {
-                       $data['inbox'] = DI::baseUrl() . '/friendica/inbox';
+                       $data['inbox']  = DI::baseUrl() . '/friendica/inbox';
+                       $data['outbox'] = DI::baseUrl() . '/friendica/outbox';
                }
 
                $data['preferredUsername'] = $owner['nick'];
@@ -978,13 +979,12 @@ class Transmitter
         * Fetches a list of inboxes of followers of a given user
         *
         * @param integer $uid      User ID
-        * @param boolean $personal fetch personal inboxes
         * @param boolean $all_ap   Retrieve all AP enabled inboxes
         * @return array of follower inboxes
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       public static function fetchTargetInboxesforUser(int $uid, bool $personal = false, bool $all_ap = false): array
+       public static function fetchTargetInboxesforUser(int $uid, bool $all_ap = false): array
        {
                $inboxes = [];
 
@@ -1034,7 +1034,7 @@ class Transmitter
 
                        $profile = APContact::getByURL($contact['url'], false);
                        if (!empty($profile)) {
-                               if (empty($profile['sharedinbox']) || $personal || Contact::isLocal($contact['url'])) {
+                               if (empty($profile['sharedinbox']) || Contact::isLocal($contact['url'])) {
                                        $target = $profile['inbox'];
                                } else {
                                        $target = $profile['sharedinbox'];
@@ -1054,12 +1054,11 @@ class Transmitter
         *
         * @param array   $item     Item array
         * @param integer $uid      User ID
-        * @param boolean $personal fetch personal inboxes
         * @return array with inboxes
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       public static function fetchTargetInboxes(array $item, int $uid, bool $personal = false): array
+       public static function fetchTargetInboxes(array $item, int $uid): array
        {
                $permissions = self::getReceiversForUriId($item['uri-id'], true);
                if (empty($permissions)) {
@@ -1093,13 +1092,13 @@ class Transmitter
                                }
 
                                if ($item_profile && ($receiver == $item_profile['followers']) && ($uid == $profile_uid)) {
-                                       $inboxes = array_merge_recursive($inboxes, self::fetchTargetInboxesforUser($uid, $personal, true));
+                                       $inboxes = array_merge_recursive($inboxes, self::fetchTargetInboxesforUser($uid, true));
                                } else {
                                        $profile = APContact::getByURL($receiver, false);
                                        if (!empty($profile)) {
                                                $contact = Contact::getByURLForUser($receiver, $uid, false, ['id']);
 
-                                               if (empty($profile['sharedinbox']) || $personal || $blindcopy || Contact::isLocal($receiver)) {
+                                               if (empty($profile['sharedinbox']) || $blindcopy || Contact::isLocal($receiver)) {
                                                        $target = $profile['inbox'];
                                                } else {
                                                        $target = $profile['sharedinbox'];
@@ -1115,6 +1114,27 @@ class Transmitter
                return $inboxes;
        }
 
+       /**
+        * Fetch the target inboxes for a given mail id
+        *
+        * @param integer $mail_id
+        * @return array
+        */
+       public static function fetchTargetInboxesFromMail(int $mail_id): array
+       {
+               $mail = DBA::selectFirst('mail', ['contact-id'], ['id' => $mail_id]);
+               if (!DBA::isResult($mail)) {
+                       return [];
+               }
+
+               $account = DBA::selectFirst('account-user-view', ['ap-inbox'], ['id' => $mail['contact-id']]);
+               if (empty($account['ap-inbox'])) {
+                       return [];
+               }
+
+               return [$account['ap-inbox'] => [$mail['contact-id']]];
+       }
+
        /**
         * Creates an array in the structure of the item table for a given mail id
         *