X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FObject%2FApi%2FMastodon%2FStatus.php;h=cefae5d2129cbdb8574c977fcc63c128800d0053;hb=6ffd3a3f8ce4f1b08d51e710fbb228ad23957f7a;hp=1e778a7108dea6081d81fc6dfcd73f8d777c17d7;hpb=6aa1dcfad371f34fea1f8e39b73de2cc3dd05784;p=friendica.git diff --git a/src/Object/Api/Mastodon/Status.php b/src/Object/Api/Mastodon/Status.php index 1e778a7108..cefae5d212 100644 --- a/src/Object/Api/Mastodon/Status.php +++ b/src/Object/Api/Mastodon/Status.php @@ -25,6 +25,7 @@ use Friendica\BaseDataTransferObject; use Friendica\Content\Text\BBCode; use Friendica\Model\Item; use Friendica\Object\Api\Mastodon\Status\Counts; +use Friendica\Object\Api\Mastodon\Status\FriendicaExtension; use Friendica\Object\Api\Mastodon\Status\UserAttributes; use Friendica\Util\DateTimeFormat; @@ -41,6 +42,8 @@ class Status extends BaseDataTransferObject protected $created_at; /** @var string|null */ protected $in_reply_to_id = null; + /** @var Status|null - Fedilab extension, see issue https://github.com/friendica/friendica/issues/12672 */ + protected $in_reply_to_status = null; /** @var string|null */ protected $in_reply_to_account_id = null; /** @var bool */ @@ -75,6 +78,8 @@ class Status extends BaseDataTransferObject protected $content; /** @var Status|null */ protected $reblog = null; + /** @var Status|null - Akkoma extension, see issue https://github.com/friendica/friendica/issues/12603 */ + protected $quote = null; /** @var Application */ protected $application = null; /** @var Account */ @@ -91,6 +96,8 @@ class Status extends BaseDataTransferObject protected $card = null; /** @var Poll|null */ protected $poll = null; + /** @var FriendicaExtension */ + protected $friendica; /** * Creates a status record from an item record. @@ -98,13 +105,14 @@ 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 $in_reply, array $reblog, FriendicaExtension $friendica, array $quote = null, array $poll = null) { $this->id = (string)$item['uri-id']; $this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON); if ($item['gravity'] == Item::GRAVITY_COMMENT) { $this->in_reply_to_id = (string)$item['thr-parent-id']; + $this->in_reply_to_status = $in_reply; $this->in_reply_to_account_id = (string)$item['parent-author-id']; } @@ -134,6 +142,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; @@ -142,6 +151,22 @@ class Status extends BaseDataTransferObject $this->emojis = []; $this->card = $card->toArray() ?: null; $this->poll = $poll; + $this->friendica = $friendica; + } + + /** + * Returns the current created_at DateTime as an integer timestamp + * @return int + * @throws \Exception + */ + public function createdAtTimestamp(): int + { + $result = strtotime($this->created_at); + if (!$result) { + throw new \Exception('Unknown date-time format'); + } + + return $result; } /** @@ -165,6 +190,14 @@ class Status extends BaseDataTransferObject $status['reblog'] = null; } + if (empty($status['quote'])) { + $status['quote'] = null; + } + + if (empty($status['in_reply_to_status'])) { + $status['in_reply_to_status'] = null; + } + return $status; } }