From fcbf557bd2c4db3734e328ffe434895457836478 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Tue, 30 Apr 2019 21:51:24 +0200 Subject: Add site-wide options to show reblogs and replies in local/public timelines Fixes #1021 --- app/models/form/admin_settings.rb | 4 ++++ app/models/status.rb | 12 ++++++++---- app/services/fan_out_on_write_service.rb | 5 +++-- app/views/admin/settings/edit.html.haml | 6 ++++++ 4 files changed, 21 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index f81776346..0e9bfb265 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -32,6 +32,8 @@ class Form::AdminSettings thumbnail hero mascot + show_reblogs_in_public_timelines + show_replies_in_public_timelines ).freeze BOOLEAN_KEYS = %i( @@ -45,6 +47,8 @@ class Form::AdminSettings profile_directory hide_followers_count enable_keybase + show_reblogs_in_public_timelines + show_replies_in_public_timelines ).freeze UPLOAD_KEYS = %i( diff --git a/app/models/status.rb b/app/models/status.rb index e7fa0220b..1b905d5b8 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -327,7 +327,8 @@ class Status < ApplicationRecord end def as_public_timeline(account = nil, local_only = false) - query = timeline_scope(local_only).without_replies + query = timeline_scope(local_only) + query = query.without_replies unless Setting.show_replies_in_public_timelines apply_timeline_filters(query, account, local_only) end @@ -408,9 +409,12 @@ class Status < ApplicationRecord def timeline_scope(local_only = false) starting_scope = local_only ? Status.local : Status - starting_scope - .with_public_visibility - .without_reblogs + starting_scope = starting_scope.with_public_visibility + if Setting.show_reblogs_in_public_timelines + starting_scope + else + starting_scope.without_reblogs + end end def apply_timeline_filters(query, account, local_only) diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb index de7c031d8..b66dc342e 100644 --- a/app/services/fan_out_on_write_service.rb +++ b/app/services/fan_out_on_write_service.rb @@ -21,11 +21,12 @@ class FanOutOnWriteService < BaseService deliver_to_lists(status) end - return if status.account.silenced? || !status.public_visibility? || status.reblog? + return if status.account.silenced? || !status.public_visibility? + return if status.reblog? && !Setting.show_reblogs_in_public_timelines deliver_to_hashtags(status) - return if status.reply? && status.in_reply_to_account_id != status.account_id + return if status.reply? && status.in_reply_to_account_id != status.account_id && !Setting.show_replies_in_public_timelines deliver_to_public(status) deliver_to_media(status) if status.media_attachments.any? diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml index 8f7acde5f..a8c9f6a58 100644 --- a/app/views/admin/settings/edit.html.haml +++ b/app/views/admin/settings/edit.html.haml @@ -72,6 +72,12 @@ .fields-group = f.input :enable_keybase, as: :boolean, wrapper: :with_label, label: t('admin.settings.enable_keybase.title'), hint: t('admin.settings.enable_keybase.desc_html') + .fields-group + = f.input :show_reblogs_in_public_timelines, as: :boolean, wrapper: :with_label, label: t('admin.settings.show_reblogs_in_public_timelines.title'), hint: t('admin.settings.show_reblogs_in_public_timelines.desc_html') + + .fields-group + = f.input :show_replies_in_public_timelines, as: :boolean, wrapper: :with_label, label: t('admin.settings.show_replies_in_public_timelines.title'), hint: t('admin.settings.show_replies_in_public_timelines.desc_html') + %hr.spacer/ .fields-group -- cgit