Option to define how posts with titles are transmitted

This commit is contained in:
Michael 2024-06-01 08:12:26 +00:00
parent e25c7d236c
commit 29187f1501
6 changed files with 175 additions and 107 deletions

View file

@ -35,6 +35,7 @@ use Friendica\Model\User;
use Friendica\Module\BaseSettings;
use Friendica\Module\Response;
use Friendica\Navigation\SystemMessages;
use Friendica\Protocol\ActivityPub;
use Friendica\Protocol\Email;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
@ -74,6 +75,7 @@ class Connectors extends BaseSettings
$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(), 'system', 'api_auto_attach', intval($request['api_auto_attach']));
$this->pconfig->set($this->session->getLocalUserId(), 'system', 'article_mode', intval($request['article_mode']));
$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'] ?? '';
@ -138,6 +140,7 @@ class Connectors extends BaseSettings
$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));
$api_auto_attach = intval($this->pconfig->get($this->session->getLocalUserId(), 'system', 'api_auto_attach', false));
$article_mode = intval($this->pconfig->get($this->session->getLocalUserId(), 'system', 'article_mode'));
$legacy_contact = $this->pconfig->get($this->session->getLocalUserId(), 'ostatus', 'legacy_contact');
if (!empty($legacy_contact)) {
@ -197,6 +200,12 @@ class Connectors extends BaseSettings
$ssl_options['notls'] = $this->t('None');
}
$article_modes = [
ActivityPub::ARTICLE_DEFAULT => $this->t('Default (Mastodon will display the title and a link to the post)'),
ActivityPub::ARTICLE_USE_SUMMARY => $this->t('Use the summary (Mastodon and some others will treat it as content warning)'),
ActivityPub::ARTICLE_EMBED_TITLE => $this->t('Embed the title in the body')
];
$tpl = Renderer::getMarkupTemplate('settings/connectors.tpl');
$o = Renderer::replaceMacros($tpl, [
'$form_security_token' => BaseSettings::getFormSecurityToken("settings_connectors"),
@ -224,6 +233,7 @@ class Connectors extends BaseSettings
'$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.')],
'$api_auto_attach' => ['api_auto_attach', $this->t('API: Automatically links at the end of the post as attached posts'), $api_auto_attach, $this->t('When activated, added links at the end of the post react the same way as added links in the web interface.')],
'$article_mode' => ['article_mode', $this->t('Article Mode'), $article_mode, $this->t("Controls how posts with titles are transmitted. Mastodon and its forks don't display the content of these posts if the post is created in the correct (default) way."), $article_modes],
'$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'),