From: Hank Grabowski <hankgrabowski@gmail.com>
Date: Sat, 27 May 2023 01:37:08 +0000 (-0400)
Subject: Fix Mastodon API Reshared statuses are a stub w/content in reblog field
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8d9e0b4eaec2bfb9629cd75d34cd777709d03b2f;p=friendica.git

Fix Mastodon API Reshared statuses are a stub w/content in reblog field
---

diff --git a/src/Object/Api/Mastodon/Status.php b/src/Object/Api/Mastodon/Status.php
index 0a02a48549..122e62f9ca 100644
--- a/src/Object/Api/Mastodon/Status.php
+++ b/src/Object/Api/Mastodon/Status.php
@@ -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;
 	}
 
 	/**