]> git.mxchange.org Git - friendica.git/commitdiff
Issue 12603: Support quotes in the API
authorMichael <heluecht@pirati.ca>
Mon, 23 Jan 2023 19:00:20 +0000 (19:00 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 23 Jan 2023 19:00:20 +0000 (19:00 +0000)
src/Factory/Api/Mastodon/Status.php
src/Object/Api/Mastodon/Status.php

index b32a6c510f9a0df7f0442f7e14ce2dbede534474..bac9d18035324ba9858df9676ee7064ab2e8a5e5 100644 (file)
@@ -234,7 +234,13 @@ class Status extends BaseFactory
                        $reshare = [];
                }
 
-               return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $reshare, $poll);
+               if (!empty($item['quote-uri-id'])) {
+                       $quote = $this->createFromUriId($item['quote-uri-id'], $uid, false)->toArray();
+               } else {
+                       $quote = [];
+               }
+
+               return new \Friendica\Object\Api\Mastodon\Status($item, $account, $counts, $userAttributes, $sensitive, $application, $mentions, $tags, $card, $attachments, $reshare, $quote, $poll);
        }
 
        /**
index 1e778a7108dea6081d81fc6dfcd73f8d777c17d7..2fcbb10e3a7fa6d23c12b63ed9f6d5c85bea1aa2 100644 (file)
@@ -75,6 +75,8 @@ class Status extends BaseDataTransferObject
        protected $content;
        /** @var Status|null */
        protected $reblog = null;
+       /** @var Status|null */
+       protected $quote = null;
        /** @var Application */
        protected $application = null;
        /** @var Account */
@@ -98,7 +100,7 @@ class Status extends BaseDataTransferObject
         * @param array   $item
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public function __construct(array $item, Account $account, Counts $counts, UserAttributes $userAttributes, bool $sensitive, Application $application, array $mentions, array $tags, Card $card, array $attachments, array $reblog, array $poll = null)
+       public function __construct(array $item, Account $account, Counts $counts, UserAttributes $userAttributes, bool $sensitive, Application $application, array $mentions, array $tags, Card $card, array $attachments, array $reblog, array $quote = null, array $poll = null)
        {
                $this->id         = (string)$item['uri-id'];
                $this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON);
@@ -134,6 +136,7 @@ class Status extends BaseDataTransferObject
                $this->pinned = $userAttributes->pinned;
                $this->content = 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;
@@ -165,6 +168,10 @@ class Status extends BaseDataTransferObject
                        $status['reblog'] = null;
                }
 
+               if (empty($status['quote'])) {
+                       $status['quote'] = null;
+               }
+
                return $status;
        }
 }