Merge pull request #11305 from annando/api-spoiler

API: Improve support for the summary field
This commit is contained in:
Hypolite Petovan 2022-03-08 15:48:46 -05:00 committed by GitHub
commit c13ae36256
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 5 deletions

View File

@ -76,8 +76,8 @@ class Status extends BaseFactory
*/ */
public function createFromUriId(int $uriId, $uid = 0): \Friendica\Object\Api\Mastodon\Status 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', $fields = ['uri-id', 'uid', 'author-id', 'author-link', 'starred', 'app', 'title', 'body', 'raw-body', 'content-warning',
'thr-parent-id', 'parent-author-id', 'language', 'uri', 'plink', 'private', 'vid', 'gravity']; '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]]); $item = Post::selectFirst($fields, ['uri-id' => $uriId, 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
if (!$item) { if (!$item) {
$mail = DBA::selectFirst('mail', ['id'], ['uri-id' => $uriId, 'uid' => $uid]); $mail = DBA::selectFirst('mail', ['id'], ['uri-id' => $uriId, 'uid' => $uid]);

View File

@ -69,7 +69,6 @@ class Statuses extends BaseApi
$item['verb'] = Activity::POST; $item['verb'] = Activity::POST;
$item['contact-id'] = $owner['id']; $item['contact-id'] = $owner['id'];
$item['author-id'] = $item['owner-id'] = Contact::getPublicIdByUserId($uid); $item['author-id'] = $item['owner-id'] = Contact::getPublicIdByUserId($uid);
$item['title'] = $request['spoiler_text'];
$item['body'] = $body; $item['body'] = $body;
if (!empty(self::getCurrentApplication()['name'])) { if (!empty(self::getCurrentApplication()['name'])) {
@ -141,14 +140,17 @@ class Statuses extends BaseApi
if ($request['in_reply_to_id']) { if ($request['in_reply_to_id']) {
$parent = Post::selectFirst(['uri'], ['uri-id' => $request['in_reply_to_id'], 'uid' => [0, $uid]]); $parent = Post::selectFirst(['uri'], ['uri-id' => $request['in_reply_to_id'], 'uid' => [0, $uid]]);
$item['thr-parent'] = $parent['uri']; $item['thr-parent'] = $parent['uri'];
$item['gravity'] = GRAVITY_COMMENT; $item['gravity'] = GRAVITY_COMMENT;
$item['object-type'] = Activity\ObjectType::COMMENT; $item['object-type'] = Activity\ObjectType::COMMENT;
$item['body'] = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $request['spoiler_text'] . "[/abstract]\n" . $item['body'];
} else { } else {
self::checkThrottleLimit(); self::checkThrottleLimit();
$item['gravity'] = GRAVITY_PARENT; $item['gravity'] = GRAVITY_PARENT;
$item['object-type'] = Activity\ObjectType::NOTE; $item['object-type'] = Activity\ObjectType::NOTE;
$item['title'] = $request['spoiler_text'];
} }
$item = DI::contentItem()->expandTags($item, $request['visibility'] == 'direct'); $item = DI::contentItem()->expandTags($item, $request['visibility'] == 'direct');

View File

@ -108,7 +108,7 @@ class Status extends BaseDataTransferObject
} }
$this->sensitive = $sensitive; $this->sensitive = $sensitive;
$this->spoiler_text = $item['title']; $this->spoiler_text = $item['title'] ?: $item['content-warning'];
$visibility = ['public', 'private', 'unlisted']; $visibility = ['public', 'private', 'unlisted'];
$this->visibility = $visibility[$item['private']]; $this->visibility = $visibility[$item['private']];

View File

@ -911,6 +911,7 @@ class Transmitter
$mail['title'] = ''; $mail['title'] = '';
} }
$mail['content-warning'] = '';
$mail['author-link'] = $mail['owner-link'] = $mail['from-url']; $mail['author-link'] = $mail['owner-link'] = $mail['from-url'];
$mail['owner-id'] = $mail['author-id']; $mail['owner-id'] = $mail['author-id'];
$mail['allow_cid'] = '<'.$mail['contact-id'].'>'; $mail['allow_cid'] = '<'.$mail['contact-id'].'>';