]> git.mxchange.org Git - friendica.git/commitdiff
API: Improve support for the summary field
authorMichael <heluecht@pirati.ca>
Tue, 8 Mar 2022 18:32:09 +0000 (18:32 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 8 Mar 2022 18:32:09 +0000 (18:32 +0000)
src/Factory/Api/Mastodon/Status.php
src/Module/Api/Mastodon/Statuses.php
src/Object/Api/Mastodon/Status.php
src/Protocol/ActivityPub/Transmitter.php

index 002a48e6aabe4180f8bdd6b512614c114b0b83f6..9015591ad354597f5313df67749c5d921e4b7265 100644 (file)
@@ -76,8 +76,8 @@ class Status extends BaseFactory
         */
        public function createFromUriId(int $uriId, $uid = 0): \Friendica\Object\Api\Mastodon\Status
        {
-               $fields = ['uri-id', 'uid', 'author-id', 'author-link', 'starred', 'app', 'title', 'body', 'raw-body', 'created', 'network',
-                       'thr-parent-id', 'parent-author-id', 'language', 'uri', 'plink', 'private', 'vid', 'gravity'];
+               $fields = ['uri-id', 'uid', 'author-id', 'author-link', 'starred', 'app', 'title', 'body', 'raw-body', 'content-warning',
+                       'created', 'network', 'thr-parent-id', 'parent-author-id', 'language', 'uri', 'plink', 'private', 'vid', 'gravity'];
                $item = Post::selectFirst($fields, ['uri-id' => $uriId, 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
                if (!$item) {
                        $mail = DBA::selectFirst('mail', ['id'], ['uri-id' => $uriId, 'uid' => $uid]);
index 4cb9bdb1dc9ecd441fbf7a3a1a4fd79ccd022a6f..50e0eaa725a980e50752592c45f801368c7a430c 100644 (file)
@@ -69,7 +69,6 @@ class Statuses extends BaseApi
                $item['verb']       = Activity::POST;
                $item['contact-id'] = $owner['id'];
                $item['author-id']  = $item['owner-id'] = Contact::getPublicIdByUserId($uid);
-               $item['title']      = $request['spoiler_text'];
                $item['body']       = $body;
 
                if (!empty(self::getCurrentApplication()['name'])) {
@@ -141,14 +140,17 @@ class Statuses extends BaseApi
 
                if ($request['in_reply_to_id']) {
                        $parent = Post::selectFirst(['uri'], ['uri-id' => $request['in_reply_to_id'], 'uid' => [0, $uid]]);
+
                        $item['thr-parent']  = $parent['uri'];
                        $item['gravity']     = GRAVITY_COMMENT;
                        $item['object-type'] = Activity\ObjectType::COMMENT;
+                       $item['body']        = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $request['spoiler_text'] . "[/abstract]\n" . $item['body'];
                } else {
                        self::checkThrottleLimit();
 
                        $item['gravity']     = GRAVITY_PARENT;
                        $item['object-type'] = Activity\ObjectType::NOTE;
+                       $item['title']       = $request['spoiler_text'];
                }
 
                $item = DI::contentItem()->expandTags($item, $request['visibility'] == 'direct');
index 987cf00e6ac0eca69b4e7b7b6df7c7cbbb2cf9ad..12fef7ac8f0676a7e3fb37b6bde1458e61a751b4 100644 (file)
@@ -107,8 +107,8 @@ class Status extends BaseDataTransferObject
                        $this->in_reply_to_account_id = (string)$item['parent-author-id'];
                }
 
-               $this->sensitive = $sensitive;
-               $this->spoiler_text = $item['title'];
+               $this->sensitive    = $sensitive;
+               $this->spoiler_text = $item['title'] ?: $item['content-warning'];
 
                $visibility = ['public', 'private', 'unlisted'];
                $this->visibility = $visibility[$item['private']];
index c65265396ed5068dda232f0fd1d0550e418b974f..47c3cdaab5d1a3f40465d2dc1a7857c3d818c0ae 100644 (file)
@@ -911,6 +911,7 @@ class Transmitter
                        $mail['title']        = '';
                }
 
+               $mail['content-warning']  = '';
                $mail['author-link']      = $mail['owner-link'] = $mail['from-url'];
                $mail['owner-id']         = $mail['author-id'];
                $mail['allow_cid']        = '<'.$mail['contact-id'].'>';