Merge pull request #12720 from annando/issue-12702

Issue 12702: Let the user decide how to handle spoiler texts
This commit is contained in:
Hypolite Petovan 2023-01-23 08:40:47 -05:00 committed by GitHub
commit e959d9e454
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 77 additions and 54 deletions

View file

@ -71,17 +71,17 @@ class Statuses extends BaseApi
} }
// The imput is defined as text. So we can use Markdown for some enhancements // 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'])) { if (!empty($request['language'])) {
$item['language'] = json_encode([$request['language'] => 1]); $item['language'] = json_encode([$request['language'] => 1]);
} }
if (!empty($request['spoiler_text'])) { if (!empty($request['spoiler_text'])) {
if ($request['in_reply_to_id'] != $post['uri-id']) { if (($request['in_reply_to_id'] == $post['uri-id']) && DI::pConfig()->get($uid, 'system', 'api_spoiler_title', true)) {
$item['body'] = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $request['spoiler_text'] . "[/abstract]\n" . $item['body'];
} else {
$item['title'] = $request['spoiler_text']; $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['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'] = '';
$item['body'] = $body; $item['body'] = $body;
$item['app'] = $this->getApp(); $item['app'] = $this->getApp();
@ -187,13 +188,19 @@ class Statuses extends BaseApi
$item['thr-parent'] = $parent['uri']; $item['thr-parent'] = $parent['uri'];
$item['gravity'] = Item::GRAVITY_COMMENT; $item['gravity'] = Item::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'] = Item::GRAVITY_PARENT; $item['gravity'] = Item::GRAVITY_PARENT;
$item['object-type'] = Activity\ObjectType::NOTE; $item['object-type'] = Activity\ObjectType::NOTE;
}
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']; $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'); $item = DI::contentItem()->expandTags($item, $request['visibility'] == 'direct');

View file

@ -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', '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', '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', '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']); $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')) { } elseif (!empty($request['mail-submit']) && function_exists('imap_open') && !$this->config->get('system', 'imap_disabled')) {
$mail_server = $request['mail_server'] ?? ''; $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')); $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')); $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')); $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'); $legacy_contact = $this->pconfig->get($this->session->getLocalUserId(), 'ostatus', 'legacy_contact');
if (!empty($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.')], '$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.')], '$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.')], '$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 standalone posts. When deactivated it will be used for spoiler text. For comments it will always be used for spoiler text.')],
'$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.')], '$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_url' => 'ostatus/repair',
'$repair_ostatus_text' => $this->t('Repair OStatus subscriptions'), '$repair_ostatus_text' => $this->t('Repair OStatus subscriptions'),

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 2023.03-dev\n" "Project-Id-Version: 2023.03-dev\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-01-23 06:36+0000\n" "POT-Creation-Date: 2023-01-23 06:47+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -625,7 +625,7 @@ msgstr ""
#: src/Module/Moderation/Users/Active.php:136 #: src/Module/Moderation/Users/Active.php:136
#: src/Module/Moderation/Users/Blocked.php:136 #: src/Module/Moderation/Users/Blocked.php:136
#: src/Module/Moderation/Users/Index.php:151 #: src/Module/Moderation/Users/Index.php:151
#: src/Module/Settings/Connectors.php:239 #: src/Module/Settings/Connectors.php:241
msgid "Delete" msgid "Delete"
msgstr "" msgstr ""
@ -1825,7 +1825,7 @@ msgstr ""
msgid "See all notifications" msgid "See all notifications"
msgstr "" msgstr ""
#: src/Content/Nav.php:315 src/Module/Settings/Connectors.php:239 #: src/Content/Nav.php:315 src/Module/Settings/Connectors.php:241
msgid "Mark as seen" msgid "Mark as seen"
msgstr "" msgstr ""
@ -3663,8 +3663,8 @@ msgstr ""
#: src/Module/Admin/Logs/Settings.php:81 src/Module/Admin/Site.php:438 #: src/Module/Admin/Logs/Settings.php:81 src/Module/Admin/Site.php:438
#: src/Module/Admin/Themes/Index.php:113 src/Module/Admin/Tos.php:86 #: src/Module/Admin/Themes/Index.php:113 src/Module/Admin/Tos.php:86
#: src/Module/Settings/Account.php:560 src/Module/Settings/Addons.php:78 #: src/Module/Settings/Account.php:560 src/Module/Settings/Addons.php:78
#: src/Module/Settings/Connectors.php:156 #: src/Module/Settings/Connectors.php:158
#: src/Module/Settings/Connectors.php:241 #: src/Module/Settings/Connectors.php:243
#: src/Module/Settings/Delegation.php:169 src/Module/Settings/Display.php:247 #: src/Module/Settings/Delegation.php:169 src/Module/Settings/Display.php:247
#: src/Module/Settings/Features.php:76 #: src/Module/Settings/Features.php:76
msgid "Save Settings" msgid "Save Settings"
@ -5476,7 +5476,7 @@ msgstr ""
msgid "Display" msgid "Display"
msgstr "" msgstr ""
#: src/Module/BaseSettings.php:127 src/Module/Settings/Connectors.php:200 #: src/Module/BaseSettings.php:127 src/Module/Settings/Connectors.php:202
msgid "Social Networks" msgid "Social Networks"
msgstr "" msgstr ""
@ -9365,73 +9365,73 @@ msgstr ""
msgid "No Addon settings configured" msgid "No Addon settings configured"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:118 #: src/Module/Settings/Connectors.php:119
msgid "Failed to connect with email account using the settings provided." msgid "Failed to connect with email account using the settings provided."
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:162 #: src/Module/Settings/Connectors.php:164
#: src/Module/Settings/Connectors.php:163 #: src/Module/Settings/Connectors.php:165
msgid "Diaspora (Socialhome, Hubzilla)" msgid "Diaspora (Socialhome, Hubzilla)"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:162 #: src/Module/Settings/Connectors.php:164
#: src/Module/Settings/Connectors.php:166 #: src/Module/Settings/Connectors.php:168
#, php-format #, php-format
msgid "Built-in support for %s connectivity is enabled" msgid "Built-in support for %s connectivity is enabled"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:163
#: src/Module/Settings/Connectors.php:165 #: src/Module/Settings/Connectors.php:165
#: src/Module/Settings/Connectors.php:167
#, php-format #, php-format
msgid "Built-in support for %s connectivity is disabled" msgid "Built-in support for %s connectivity is disabled"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:165 #: src/Module/Settings/Connectors.php:167
#: src/Module/Settings/Connectors.php:166 #: src/Module/Settings/Connectors.php:168
msgid "OStatus (GNU Social)" msgid "OStatus (GNU Social)"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:178 #: src/Module/Settings/Connectors.php:180
msgid "Email access is disabled on this site." msgid "Email access is disabled on this site."
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:193 #: src/Module/Settings/Connectors.php:195
#: src/Module/Settings/Connectors.php:239 #: src/Module/Settings/Connectors.php:241
msgid "None" msgid "None"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:205 #: src/Module/Settings/Connectors.php:207
msgid "General Social Media Settings" msgid "General Social Media Settings"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:208 #: src/Module/Settings/Connectors.php:210
msgid "Followed content scope" msgid "Followed content scope"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:210 #: src/Module/Settings/Connectors.php:212
msgid "" msgid ""
"By default, conversations in which your follows participated but didn't " "By default, conversations in which your follows participated but didn't "
"start will be shown in your timeline. You can turn this behavior off, or " "start will be shown in your timeline. You can turn this behavior off, or "
"expand it to the conversations in which your follows liked a post." "expand it to the conversations in which your follows liked a post."
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:212 #: src/Module/Settings/Connectors.php:214
msgid "Only conversations my follows started" msgid "Only conversations my follows started"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:213 #: src/Module/Settings/Connectors.php:215
msgid "Conversations my follows started or commented on (default)" msgid "Conversations my follows started or commented on (default)"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:214 #: src/Module/Settings/Connectors.php:216
msgid "Any conversation my follows interacted with, including likes" msgid "Any conversation my follows interacted with, including likes"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:217 #: src/Module/Settings/Connectors.php:219
msgid "Enable Content Warning" msgid "Enable Content Warning"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:217 #: src/Module/Settings/Connectors.php:219
msgid "" msgid ""
"Users on networks like Mastodon or Pleroma are able to set a content warning " "Users on networks like Mastodon or Pleroma are able to set a content warning "
"field which collapse their post by default. This enables the automatic " "field which collapse their post by default. This enables the automatic "
@ -9439,104 +9439,115 @@ msgid ""
"affect any other content filtering you eventually set up." "affect any other content filtering you eventually set up."
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:218 #: src/Module/Settings/Connectors.php:220
msgid "Enable intelligent shortening" msgid "Enable intelligent shortening"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:218 #: src/Module/Settings/Connectors.php:220
msgid "" msgid ""
"Normally the system tries to find the best link to add to shortened posts. " "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 " "If disabled, every shortened post will always point to the original "
"friendica post." "friendica post."
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:219 #: src/Module/Settings/Connectors.php:221
msgid "Enable simple text shortening" msgid "Enable simple text shortening"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:219 #: src/Module/Settings/Connectors.php:221
msgid "" msgid ""
"Normally the system shortens posts at the next line feed. If this option is " "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." "enabled then the system will shorten the text at the maximum character limit."
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:220 #: src/Module/Settings/Connectors.php:222
msgid "Attach the link title" msgid "Attach the link title"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:220 #: src/Module/Settings/Connectors.php:222
msgid "" msgid ""
"When activated, the title of the attached link will be added as a title on " "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 " "posts to Diaspora. This is mostly helpful with \"remote-self\" contacts that "
"share feed content." "share feed content."
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:221 #: src/Module/Settings/Connectors.php:223
msgid "API: Use spoiler field as title"
msgstr ""
#: src/Module/Settings/Connectors.php:223
msgid ""
"When activated, the \"spoiler_text\" field in the API will be used for the "
"title on standalone posts. When deactivated it will be used for spoiler "
"text. For comments it will always be used for spoiler text."
msgstr ""
#: src/Module/Settings/Connectors.php:224
msgid "Your legacy ActivityPub/GNU Social account" msgid "Your legacy ActivityPub/GNU Social account"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:221 #: src/Module/Settings/Connectors.php:224
msgid "" msgid ""
"If you enter your old account name from an ActivityPub based system or your " "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 " "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." "contacts will be added automatically. The field will be emptied when done."
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:224 #: src/Module/Settings/Connectors.php:226
msgid "Repair OStatus subscriptions" msgid "Repair OStatus subscriptions"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:228 #: src/Module/Settings/Connectors.php:230
msgid "Email/Mailbox Setup" msgid "Email/Mailbox Setup"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:229 #: src/Module/Settings/Connectors.php:231
msgid "" msgid ""
"If you wish to communicate with email contacts using this service " "If you wish to communicate with email contacts using this service "
"(optional), please specify how to connect to your mailbox." "(optional), please specify how to connect to your mailbox."
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:230 #: src/Module/Settings/Connectors.php:232
msgid "Last successful email check:" msgid "Last successful email check:"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:232 #: src/Module/Settings/Connectors.php:234
msgid "IMAP server name:" msgid "IMAP server name:"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:233 #: src/Module/Settings/Connectors.php:235
msgid "IMAP port:" msgid "IMAP port:"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:234 #: src/Module/Settings/Connectors.php:236
msgid "Security:" msgid "Security:"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:235 #: src/Module/Settings/Connectors.php:237
msgid "Email login name:" msgid "Email login name:"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:236 #: src/Module/Settings/Connectors.php:238
msgid "Email password:" msgid "Email password:"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:237 #: src/Module/Settings/Connectors.php:239
msgid "Reply-to address:" msgid "Reply-to address:"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:238 #: src/Module/Settings/Connectors.php:240
msgid "Send public posts to all email contacts:" msgid "Send public posts to all email contacts:"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:239 #: src/Module/Settings/Connectors.php:241
msgid "Action after import:" msgid "Action after import:"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:239 #: src/Module/Settings/Connectors.php:241
msgid "Move to folder" msgid "Move to folder"
msgstr "" msgstr ""
#: src/Module/Settings/Connectors.php:240 #: src/Module/Settings/Connectors.php:242
msgid "Move to folder:" msgid "Move to folder:"
msgstr "" msgstr ""

View file

@ -16,6 +16,7 @@
{{include file="field_checkbox.tpl" field=$enable_smart_shortening}} {{include file="field_checkbox.tpl" field=$enable_smart_shortening}}
{{include file="field_checkbox.tpl" field=$simple_shortening}} {{include file="field_checkbox.tpl" field=$simple_shortening}}
{{include file="field_checkbox.tpl" field=$attach_link_title}} {{include file="field_checkbox.tpl" field=$attach_link_title}}
{{include file="field_checkbox.tpl" field=$api_spoiler_title}}
{{include file="field_input.tpl" field=$legacy_contact}} {{include file="field_input.tpl" field=$legacy_contact}}
<p><a href="{{$repair_ostatus_url}}">{{$repair_ostatus_text}}</a></p> <p><a href="{{$repair_ostatus_url}}">{{$repair_ostatus_text}}</a></p>

View file

@ -28,6 +28,8 @@
{{include file="field_checkbox.tpl" field=$attach_link_title}} {{include file="field_checkbox.tpl" field=$attach_link_title}}
{{include file="field_checkbox.tpl" field=$api_spoiler_title}}
{{include file="field_input.tpl" field=$legacy_contact}} {{include file="field_input.tpl" field=$legacy_contact}}
<p><a href="{{$repair_ostatus_url}}">{{$repair_ostatus_text}}</a></p> <p><a href="{{$repair_ostatus_url}}">{{$repair_ostatus_text}}</a></p>