mirror of
https://github.com/friendica/friendica
synced 2025-04-23 22:30:10 +00:00
Issue 12702: Let the user decide how to handle spoiler texts
This commit is contained in:
parent
2db935fae2
commit
8e4e2eecb7
5 changed files with 78 additions and 55 deletions
|
@ -71,17 +71,17 @@ class Statuses extends BaseApi
|
|||
}
|
||||
|
||||
// The imput is defined as text. So we can use Markdown for some enhancements
|
||||
$item = ['body' => Markdown::toBBCode($request['status']), 'app' => $this->getApp()];
|
||||
$item = ['body' => Markdown::toBBCode($request['status']), 'app' => $this->getApp(), 'title' => ''];
|
||||
|
||||
if (!empty($request['language'])) {
|
||||
$item['language'] = json_encode([$request['language'] => 1]);
|
||||
}
|
||||
|
||||
if (!empty($request['spoiler_text'])) {
|
||||
if ($request['in_reply_to_id'] != $post['uri-id']) {
|
||||
$item['body'] = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $request['spoiler_text'] . "[/abstract]\n" . $item['body'];
|
||||
} else {
|
||||
if (($request['in_reply_to_id'] == $post['uri-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'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,7 @@ class Statuses extends BaseApi
|
|||
$item['verb'] = Activity::POST;
|
||||
$item['contact-id'] = $owner['id'];
|
||||
$item['author-id'] = $item['owner-id'] = Contact::getPublicIdByUserId($uid);
|
||||
$item['title'] = '';
|
||||
$item['body'] = $body;
|
||||
$item['app'] = $this->getApp();
|
||||
|
||||
|
@ -187,13 +188,19 @@ class Statuses extends BaseApi
|
|||
$item['thr-parent'] = $parent['uri'];
|
||||
$item['gravity'] = Item::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'] = Item::GRAVITY_PARENT;
|
||||
$item['object-type'] = Activity\ObjectType::NOTE;
|
||||
$item['title'] = $request['spoiler_text'];
|
||||
}
|
||||
|
||||
if (!empty($request['spoiler_text'])) {
|
||||
if (!$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'];
|
||||
}
|
||||
}
|
||||
|
||||
$item = DI::contentItem()->expandTags($item, $request['visibility'] == 'direct');
|
||||
|
|
|
@ -72,6 +72,7 @@ class Connectors extends BaseSettings
|
|||
$this->pconfig->set($this->session->getLocalUserId(), 'system', 'no_intelligent_shortening', !intval($request['enable_smart_shortening']));
|
||||
$this->pconfig->set($this->session->getLocalUserId(), 'system', 'simple_shortening', intval($request['simple_shortening']));
|
||||
$this->pconfig->set($this->session->getLocalUserId(), 'system', 'attach_link_title', intval($request['attach_link_title']));
|
||||
$this->pconfig->set($this->session->getLocalUserId(), 'system', 'api_spoiler_title', intval($request['api_spoiler_title']));
|
||||
$this->pconfig->set($this->session->getLocalUserId(), 'ostatus', 'legacy_contact', $request['legacy_contact']);
|
||||
} elseif (!empty($request['mail-submit']) && function_exists('imap_open') && !$this->config->get('system', 'imap_disabled')) {
|
||||
$mail_server = $request['mail_server'] ?? '';
|
||||
|
@ -134,6 +135,7 @@ class Connectors extends BaseSettings
|
|||
$enable_smart_shortening = !intval($this->pconfig->get($this->session->getLocalUserId(), 'system', 'no_intelligent_shortening'));
|
||||
$simple_shortening = intval($this->pconfig->get($this->session->getLocalUserId(), 'system', 'simple_shortening'));
|
||||
$attach_link_title = intval($this->pconfig->get($this->session->getLocalUserId(), 'system', 'attach_link_title'));
|
||||
$api_spoiler_title = intval($this->pconfig->get($this->session->getLocalUserId(), 'system', 'api_spoiler_title', true));
|
||||
$legacy_contact = $this->pconfig->get($this->session->getLocalUserId(), 'ostatus', 'legacy_contact');
|
||||
|
||||
if (!empty($legacy_contact)) {
|
||||
|
@ -218,8 +220,8 @@ class Connectors extends BaseSettings
|
|||
'$enable_smart_shortening' => ['enable_smart_shortening', $this->t('Enable intelligent shortening'), $enable_smart_shortening, $this->t('Normally the system tries to find the best link to add to shortened posts. If disabled, every shortened post will always point to the original friendica post.')],
|
||||
'$simple_shortening' => ['simple_shortening', $this->t('Enable simple text shortening'), $simple_shortening, $this->t('Normally the system shortens posts at the next line feed. If this option is enabled then the system will shorten the text at the maximum character limit.')],
|
||||
'$attach_link_title' => ['attach_link_title', $this->t('Attach the link title'), $attach_link_title, $this->t('When activated, the title of the attached link will be added as a title on posts to Diaspora. This is mostly helpful with "remote-self" contacts that share feed content.')],
|
||||
'$api_spoiler_title' => ['api_spoiler_title', $this->t('API: Use spoiler field as title'), $api_spoiler_title, $this->t('When activated, the "spoiler_text" field in the API will be used for the title on staring posts. When deactivated it will be used for spoiler text. For comments it will be used for spoiler text in any case.')],
|
||||
'$legacy_contact' => ['legacy_contact', $this->t('Your legacy ActivityPub/GNU Social account'), $legacy_contact, $this->t('If you enter your old account name from an ActivityPub based system or your GNU Social/Statusnet account name here (in the format user@domain.tld), your contacts will be added automatically. The field will be emptied when done.')],
|
||||
|
||||
'$repair_ostatus_url' => 'ostatus/repair',
|
||||
'$repair_ostatus_text' => $this->t('Repair OStatus subscriptions'),
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue