From 40ee96512a3073e0d0063d5202b3551bd27abe4b Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Fri, 17 Feb 2023 17:42:00 -0500 Subject: [PATCH] Add extension to Mastodon Status object for Friendica-specific things - first entry is the title --- src/Object/Api/Mastodon/Status.php | 4 ++ .../Mastodon/Status/FriendicaExtension.php | 53 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/Object/Api/Mastodon/Status/FriendicaExtension.php diff --git a/src/Object/Api/Mastodon/Status.php b/src/Object/Api/Mastodon/Status.php index e3f322778d..bcbe1deebc 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; @@ -95,6 +96,8 @@ class Status extends BaseDataTransferObject protected $card = null; /** @var Poll|null */ protected $poll = null; + /** @var FriendicaExtension|null */ + protected $friendica = null; /** * Creates a status record from an item record. @@ -148,6 +151,7 @@ class Status extends BaseDataTransferObject $this->emojis = []; $this->card = $card->toArray() ?: null; $this->poll = $poll; + $this->friendica = new FriendicaExtension($item['title']); } /** diff --git a/src/Object/Api/Mastodon/Status/FriendicaExtension.php b/src/Object/Api/Mastodon/Status/FriendicaExtension.php new file mode 100644 index 0000000000..1a63f7606c --- /dev/null +++ b/src/Object/Api/Mastodon/Status/FriendicaExtension.php @@ -0,0 +1,53 @@ +. + * + */ + +namespace Friendica\Object\Api\Mastodon\Status; + +use Friendica\BaseDataTransferObject; + +/** + * Class FriendicaExtension + * + * Additional fields on Mastodon Statuses for storing Friendica specific data + * + * @see https://docs.joinmastodon.org/entities/status + */ +class FriendicaExtension extends BaseDataTransferObject +{ + /** @var string */ + protected $title; + + /** + * Creates a status count object + * + * @param string $title + * @throws \Friendica\Network\HTTPException\InternalServerErrorException + */ + public function __construct(string $title) + { + $this->title = $title; + } + + public function __get($name) + { + return $this->$name; + } +}