diff --git a/src/Module/Api/Mastodon/Statuses.php b/src/Module/Api/Mastodon/Statuses.php index c803835d1..01856b2d8 100644 --- a/src/Module/Api/Mastodon/Statuses.php +++ b/src/Module/Api/Mastodon/Statuses.php @@ -107,6 +107,7 @@ class Statuses extends BaseApi 'visibility' => '', // Visibility of the posted status. One of: "public", "unlisted", "private" or "direct". 'scheduled_at' => '', // ISO 8601 Datetime at which to schedule a status. Providing this paramter will cause ScheduledStatus to be returned instead of Status. Must be at least 5 minutes in the future. 'language' => '', // ISO 639 language code for this status. + 'friendica' => [], // Friendica extensions to the standard Mastodon API spec ], $request); $owner = User::getOwnerDataById($uid); @@ -208,8 +209,10 @@ class Statuses extends BaseApi $item['quote-uri-id'] = $request['quote_id']; } + $item['title'] = $request['friendica']['title'] ?? ''; + if (!empty($request['spoiler_text'])) { - if (!$request['in_reply_to_id'] && DI::pConfig()->get($uid, 'system', 'api_spoiler_title', true)) { + if (!isset($request['friendica']['title']) && !$request['in_reply_to_id'] && DI::pConfig()->get($uid, 'system', 'api_spoiler_title', true)) { $item['title'] = $request['spoiler_text']; } else { $item['body'] = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $request['spoiler_text'] . "[/abstract]\n" . $item['body']; diff --git a/src/Object/Api/Mastodon/Status.php b/src/Object/Api/Mastodon/Status.php index e3f322778..51f0b1c39 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 */ + protected $friendica; /** * 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 000000000..050c5a026 --- /dev/null +++ b/src/Object/Api/Mastodon/Status/FriendicaExtension.php @@ -0,0 +1,48 @@ +. + * + */ + +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; + } +}