summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-07-06 02:15:56 +0200
committerGitHub <noreply@github.com>2018-07-06 02:15:56 +0200
commitf89c595ea070d2017adb868fb5e311e198d8e990 (patch)
tree184c3ee83a0662b1438f2ee3a0cf02ab416e40eb
parent404c7702ec2a6576ef3b54f6a800624adfda9d53 (diff)
Add admin setting to enable OG previews for sensitive media (#7962)v2.4.3rc1
-rw-r--r--app/controllers/admin/settings_controller.rb2
-rw-r--r--app/models/form/admin_settings.rb2
-rw-r--r--app/views/admin/settings/edit.html.haml6
-rw-r--r--app/views/stream_entries/_og_image.html.haml2
-rw-r--r--config/locales/en.yml3
-rw-r--r--config/settings.yml1
6 files changed, 15 insertions, 1 deletions
diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb
index ce32082099e..75d00326c76 100644
--- a/app/controllers/admin/settings_controller.rb
+++ b/app/controllers/admin/settings_controller.rb
@@ -21,6 +21,7 @@ module Admin
activity_api_enabled
peers_api_enabled
show_known_fediverse_at_about_page
+ preview_sensitive_media
).freeze
BOOLEAN_SETTINGS = %w(
@@ -31,6 +32,7 @@ module Admin
activity_api_enabled
peers_api_enabled
show_known_fediverse_at_about_page
+ preview_sensitive_media
).freeze
UPLOAD_SETTINGS = %w(
diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb
index 32922e7f15d..723480bddb4 100644
--- a/app/models/form/admin_settings.rb
+++ b/app/models/form/admin_settings.rb
@@ -36,6 +36,8 @@ class Form::AdminSettings
:peers_api_enabled=,
:show_known_fediverse_at_about_page,
:show_known_fediverse_at_about_page=,
+ :preview_sensitive_media,
+ :preview_sensitive_media=,
to: Setting
)
end
diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml
index 08d05d7385e..f5c5deca850 100644
--- a/app/views/admin/settings/edit.html.haml
+++ b/app/views/admin/settings/edit.html.haml
@@ -2,6 +2,9 @@
= t('admin.settings.title')
= simple_form_for @admin_settings, url: admin_settings_path, html: { method: :patch } do |f|
+ .actions.actions--top
+ = f.button :button, t('generic.save_changes'), type: :submit
+
.fields-group
= f.input :site_title, placeholder: t('admin.settings.site_title')
= f.input :site_description, wrapper: :with_block_label, as: :text, label: t('admin.settings.site_description.title'), hint: t('admin.settings.site_description.desc_html'), input_html: { rows: 8 }
@@ -58,5 +61,8 @@
.fields-group
= f.input :peers_api_enabled, as: :boolean, wrapper: :with_label, label: t('admin.settings.peers_api_enabled.title'), hint: t('admin.settings.peers_api_enabled.desc_html')
+ .fields-group
+ = f.input :preview_sensitive_media, as: :boolean, wrapper: :with_label, label: t('admin.settings.preview_sensitive_media.title'), hint: t('admin.settings.preview_sensitive_media.desc_html')
+
.actions
= f.button :button, t('generic.save_changes'), type: :submit
diff --git a/app/views/stream_entries/_og_image.html.haml b/app/views/stream_entries/_og_image.html.haml
index 40530f5670c..e1b977da369 100644
--- a/app/views/stream_entries/_og_image.html.haml
+++ b/app/views/stream_entries/_og_image.html.haml
@@ -1,4 +1,4 @@
-- if activity.is_a?(Status) && activity.non_sensitive_with_media?
+- if activity.is_a?(Status) && (activity.non_sensitive_with_media? || (activity.with_media? && Setting.preview_sensitive_media))
- player_card = false
- activity.media_attachments.each do |media|
- if media.image?
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 8ab652045e1..a03b12a3972 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -316,6 +316,9 @@ en:
peers_api_enabled:
desc_html: Domain names this instance has encountered in the fediverse
title: Publish list of discovered instances
+ preview_sensitive_media:
+ desc_html: Link previews on other websites will display a thumbnail even if the media is marked as sensitive
+ title: Show sensitive media in OpenGraph previews
registrations:
closed_message:
desc_html: Displayed on frontpage when registrations are closed. You can use HTML tags
diff --git a/config/settings.yml b/config/settings.yml
index 3581d10a2eb..190f6afcd1a 100644
--- a/config/settings.yml
+++ b/config/settings.yml
@@ -26,6 +26,7 @@ defaults: &defaults
delete_modal: true
auto_play_gif: false
display_sensitive_media: false
+ preview_sensitive_media: false
reduce_motion: false
system_font_ui: false
noindex: false