From 9e04b9d8dfc57304e9c409e2bc20d838d673d432 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Sat, 30 May 2020 16:47:17 +0200 Subject: Add support for setting Content Warning for CW-less outgoing toots --- app/models/form/admin_settings.rb | 1 + app/serializers/activitypub/note_serializer.rb | 6 +++++- app/views/admin/settings/edit.html.haml | 3 +++ config/locales-glitch/en.yml | 3 +++ config/settings.yml | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index 84a656864..fcec3e686 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -41,6 +41,7 @@ class Form::AdminSettings show_domain_blocks show_domain_blocks_rationale noindex + outgoing_spoilers ).freeze BOOLEAN_KEYS = %i( diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb index dce506fa2..96e94d797 100644 --- a/app/serializers/activitypub/note_serializer.rb +++ b/app/serializers/activitypub/note_serializer.rb @@ -35,7 +35,11 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer end def summary - object.spoiler_text.presence + object.spoiler_text.presence || Setting.outgoing_spoilers.presence + end + + def sensitive + object.sensitive || Setting.outgoing_spoilers.present? end def content diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml index bff706389..108846ca9 100644 --- a/app/views/admin/settings/edit.html.haml +++ b/app/views/admin/settings/edit.html.haml @@ -108,6 +108,9 @@ .fields-row__column.fields-row__column-6.fields-group = f.input :show_domain_blocks_rationale, wrapper: :with_label, collection: %i(disabled users all), label: t('admin.settings.domain_blocks_rationale.title'), label_method: lambda { |value| t("admin.settings.domain_blocks.#{value}") }, include_blank: false, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li' + .fields-group + = f.input :outgoing_spoilers, wrapper: :with_label, label: t('admin.settings.outgoing_spoilers.title'), hint: t('admin.settings.outgoing_spoilers.desc_html') + .fields-group = f.input :site_extended_description, wrapper: :with_block_label, as: :text, label: t('admin.settings.site_description_extended.title'), hint: t('admin.settings.site_description_extended.desc_html'), input_html: { rows: 8 } unless whitelist_mode? = f.input :closed_registrations_message, as: :text, wrapper: :with_block_label, label: t('admin.settings.registrations.closed_message.title'), hint: t('admin.settings.registrations.closed_message.desc_html'), input_html: { rows: 8 } diff --git a/config/locales-glitch/en.yml b/config/locales-glitch/en.yml index c7004666a..6268727a7 100644 --- a/config/locales-glitch/en.yml +++ b/config/locales-glitch/en.yml @@ -7,6 +7,9 @@ en: enable_keybase: desc_html: Allow your users to prove their identity via keybase title: Enable keybase integration + outgoing_spoilers: + desc_html: When federating toots, add this content warning to toots that do not have one. It is useful if your server is specialized in content other servers might want to have under a Content Warning. Media will also be marked as sensitive. + title: Content warning for outgoing toots hide_followers_count: desc_html: Do not show followers count on user profiles title: Hide followers count diff --git a/config/settings.yml b/config/settings.yml index 00a4421e4..c61454e9e 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -77,6 +77,7 @@ defaults: &defaults spam_check_enabled: true show_domain_blocks: 'disabled' show_domain_blocks_rationale: 'disabled' + outgoing_spoilers: '' development: <<: *defaults -- cgit