]> git.mxchange.org Git - friendica.git/commitdiff
Add friendica->title input to Mastodon Status POST API for explicitly setting title
authorHank Grabowski <hankgrabowski@gmail.com>
Fri, 17 Feb 2023 22:42:55 +0000 (17:42 -0500)
committerHank Grabowski <hankgrabowski@gmail.com>
Fri, 17 Feb 2023 22:42:55 +0000 (17:42 -0500)
  - update logic so that if it is provided with a spoiler text then the spoiler text is always used as actual spoiler text and the title is the title.

src/Module/Api/Mastodon/Statuses.php

index c803835d1d693b967d09c621419e6036bce00b2d..60208702543a82698dfbdc7506f99373ae89c76f 100644 (file)
@@ -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,13 @@ class Statuses extends BaseApi
                        $item['quote-uri-id'] = $request['quote_id'];
                }
 
+               $has_title = array_key_exists('title', $request['friendica']);
+               if ($has_title != null && !$request['in_reply_to_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 (!$has_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'];