<?php
/**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
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;
{
/** @var string */
protected $id;
- /** @var string (Datetime) */
+ /** @var string|null (Datetime) */
protected $created_at;
+ /** @var string|null (Datetime) */
+ protected $edited_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 */
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 */
protected $card = null;
/** @var Poll|null */
protected $poll = null;
+ /** @var FriendicaExtension */
+ protected $friendica;
/**
* Creates a status record from an item record.
* @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);
+ $this->id = (string)$item['uri-id'];
+ $this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON);
+ $this->edited_at = DateTimeFormat::utc($item['edited'], 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'];
}
$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;
$this->emojis = [];
$this->card = $card->toArray() ?: null;
$this->poll = $poll;
+ $this->friendica = $friendica;
+ }
+
+ /**
+ * Returns the current created_at string or null if not set
+ * @return \DateTime|null
+ */
+ public function createdAt(): ?string
+ {
+ return $this->created_at;
+ }
+
+ /**
+ * Returns the current edited_at string or null if not set
+ * @return ?string
+ */
+ public function editedAt(): ?string
+ {
+ return $this->edited_at;
+ }
+
+ /**
+ * Returns the Friendica Extension properties
+ * @return FriendicaExtension
+ */
+ public function friendicaExtension(): FriendicaExtension
+ {
+ return $this->friendica;
}
/**
$status['reblog'] = null;
}
+ if (empty($status['quote'])) {
+ $status['quote'] = null;
+ }
+
+ if (empty($status['in_reply_to_status'])) {
+ $status['in_reply_to_status'] = null;
+ }
+
+ if ($status['created_at'] == $status['edited_at']) {
+ unset($status['edited_at']);
+ }
+
return $status;
}
}