]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/ActivityPub/Transmitter.php
Merge pull request #13580 from annando/fetch-async
[friendica.git] / src / Protocol / ActivityPub / Transmitter.php
index bda202421be5a918604d4213e78911d6768878bc..9e19724fa61b9512c1167f035374ec29e804a794 100644 (file)
@@ -337,17 +337,17 @@ class Transmitter
        /**
         * Return the ActivityPub profile of the given user
         *
-        * @param int  $uid     User ID
-        * @param bool $limited If limited, only the basic information is returned
+        * @param int  $uid  User ID
+        * @param bool $full If not full, only the basic information is returned
         * @return array with profile data
         * @throws HTTPException\NotFoundException
         * @throws HTTPException\InternalServerErrorException
         */
-       public static function getProfile(int $uid, bool $limited = false): array
+       public static function getProfile(int $uid, bool $full = true): array
        {
                $owner = User::getOwnerDataById($uid);
                if (!isset($owner['id'])) {
-                       DI::logger()->error('Unable to find owner data for uid', ['uid' => $uid, 'callstack' => System::callstack(20)]);
+                       DI::logger()->error('Unable to find owner data for uid', ['uid' => $uid]);
                        throw new HTTPException\NotFoundException('User not found.');
                }
 
@@ -373,16 +373,16 @@ class Transmitter
                $data['preferredUsername'] = $owner['nick'];
                $data['name'] = $owner['name'];
 
-               if (!$limited && !empty($owner['country-name'] . $owner['region'] . $owner['locality'])) {
+               if (!$full && !empty($owner['country-name'] . $owner['region'] . $owner['locality'])) {
                        $data['vcard:hasAddress'] = ['@type' => 'vcard:Home', 'vcard:country-name' => $owner['country-name'],
                                'vcard:region' => $owner['region'], 'vcard:locality' => $owner['locality']];
                }
 
-               if (!$limited && !empty($owner['about'])) {
+               if ($full && !empty($owner['about'])) {
                        $data['summary'] = BBCode::convertForUriId($owner['uri-id'] ?? 0, $owner['about'], BBCode::EXTERNAL);
                }
 
-               if (!$limited && (!empty($owner['xmpp']) || !empty($owner['matrix']))) {
+               if ($full && (!empty($owner['xmpp']) || !empty($owner['matrix']))) {
                        $data['vcard:hasInstantMessage'] = [];
 
                        if (!empty($owner['xmpp'])) {
@@ -400,7 +400,7 @@ class Transmitter
                        'owner' => $owner['url'],
                        'publicKeyPem' => $owner['pubkey']];
                $data['endpoints'] = ['sharedInbox' => DI::baseUrl() . '/inbox'];
-               if (!$limited && $uid != 0) {
+               if ($full && $uid != 0) {
                        $data['icon'] = ['type' => 'Image', 'url' => User::getAvatarUrl($owner)];
 
                        $resourceid = Photo::ridFromURI($owner['photo']);
@@ -1752,7 +1752,7 @@ class Transmitter
 
                        $body = BBCode::setMentionsToNicknames($body);
 
-                       if (!empty($item['quote-uri-id'])) {
+                       if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
                                if (Post::exists(['uri-id' => $item['quote-uri-id'], 'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN]])) {
                                        $real_quote = true;
                                        $data['quoteUrl'] = $item['quote-uri'];
@@ -1772,7 +1772,7 @@ class Transmitter
                if (!empty($language)) {
                        $richbody = BBCode::setMentionsToNicknames($item['body'] ?? '');
                        $richbody = Post\Media::removeFromEndOfBody($richbody);
-                       if (!empty($item['quote-uri-id'])) {
+                       if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
                                if ($real_quote) {
                                        $richbody = DI::contentItem()->addShareLink($richbody, $item['quote-uri-id']);
                                } else {
@@ -1784,7 +1784,7 @@ class Transmitter
                        $data['contentMap'][$language] = BBCode::convertForUriId($item['uri-id'], $richbody, BBCode::EXTERNAL);
                }
 
-               if (!empty($item['quote-uri-id'])) {
+               if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
                        $source = DI::contentItem()->addSharedPost($item, $item['body']);
                } else {
                        $source = $item['body'];