]> git.mxchange.org Git - friendica.git/commitdiff
Fix Mastodon API Reshared statuses are a stub w/content in reblog field
authorHank Grabowski <hankgrabowski@gmail.com>
Sat, 27 May 2023 01:37:08 +0000 (21:37 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Wed, 26 Jul 2023 17:12:23 +0000 (19:12 +0200)
src/Object/Api/Mastodon/Status.php

index 0a02a48549ce94d1eec86c5901dbb50c3efa8bfe..122e62f9caa103ec58fcdf7cc3c0e34a6cdd062f 100644 (file)
@@ -109,6 +109,7 @@ class Status extends BaseDataTransferObject
         */
        public function __construct(array $item, Account $account, Counts $counts, UserAttributes $userAttributes, bool $sensitive, Application $application, array $mentions, array $tags, Card $card, array $attachments, array $in_reply, array $reblog, FriendicaExtension $friendica, array $quote = null, array $poll = null)
        {
+               $reblogged          = !empty($reblog);
                $this->id           = (string)$item['uri-id'];
                $this->created_at   = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON);
                $this->edited_at    = DateTimeFormat::utc($item['edited'], DateTimeFormat::JSON);
@@ -135,26 +136,26 @@ class Status extends BaseDataTransferObject
 
                $this->uri = $item['uri'];
                $this->url = $item['plink'] ?? null;
-               $this->replies_count = $counts->replies;
-               $this->reblogs_count = $counts->reblogs;
-               $this->favourites_count = $counts->favourites;
+               $this->replies_count = $reblogged ? 0 : $counts->replies;
+               $this->reblogs_count = $reblogged ? 0 : $counts->reblogs;
+               $this->favourites_count = $reblogged ? 0 : $counts->favourites;
                $this->favourited = $userAttributes->favourited;
                $this->reblogged = $userAttributes->reblogged;
                $this->muted = $userAttributes->muted;
                $this->bookmarked = $userAttributes->bookmarked;
                $this->pinned = $userAttributes->pinned;
-               $this->content = BBCode::convertForUriId($item['uri-id'], BBCode::setMentionsToNicknames($item['raw-body'] ?? $item['body']), BBCode::MASTODON_API);
+               $this->content = $reblogged ? '' : BBCode::convertForUriId($item['uri-id'], BBCode::setMentionsToNicknames($item['raw-body'] ?? $item['body']), BBCode::MASTODON_API);
                $this->reblog = $reblog;
                $this->quote = $quote;
                $this->application = $application->toArray();
                $this->account = $account->toArray();
-               $this->media_attachments = $attachments;
-               $this->mentions = $mentions;
-               $this->tags = $tags;
-               $this->emojis = [];
-               $this->card = $card->toArray() ?: null;
-               $this->poll = $poll;
-               $this->friendica = $friendica;
+               $this->media_attachments = $reblogged ? [] : $attachments;
+               $this->mentions = $reblogged ? [] : $mentions;
+               $this->tags = $reblogged ? [] : $tags;
+               $this->emojis = $reblogged ? [] : [];
+               $this->card = $reblogged ? null : ($card->toArray() ?: null);
+               $this->poll = $reblogged ? null : $poll;
+               $this->friendica = $reblogged ? null : $friendica;
        }
 
        /**