Add site-wide options to show reblogs and replies in local/public timelines

Fixes #1021
This commit is contained in:
Thibaut Girka 2019-04-30 21:51:24 +02:00 committed by ThibG
parent cc5a81b7d8
commit fcbf557bd2
6 changed files with 29 additions and 6 deletions

View File

@ -32,6 +32,8 @@ class Form::AdminSettings
thumbnail thumbnail
hero hero
mascot mascot
show_reblogs_in_public_timelines
show_replies_in_public_timelines
).freeze ).freeze
BOOLEAN_KEYS = %i( BOOLEAN_KEYS = %i(
@ -45,6 +47,8 @@ class Form::AdminSettings
profile_directory profile_directory
hide_followers_count hide_followers_count
enable_keybase enable_keybase
show_reblogs_in_public_timelines
show_replies_in_public_timelines
).freeze ).freeze
UPLOAD_KEYS = %i( UPLOAD_KEYS = %i(

View File

@ -327,7 +327,8 @@ class Status < ApplicationRecord
end end
def as_public_timeline(account = nil, local_only = false) 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) apply_timeline_filters(query, account, local_only)
end end
@ -408,9 +409,12 @@ class Status < ApplicationRecord
def timeline_scope(local_only = false) def timeline_scope(local_only = false)
starting_scope = local_only ? Status.local : Status starting_scope = local_only ? Status.local : Status
starting_scope starting_scope = starting_scope.with_public_visibility
.with_public_visibility if Setting.show_reblogs_in_public_timelines
.without_reblogs starting_scope
else
starting_scope.without_reblogs
end
end end
def apply_timeline_filters(query, account, local_only) def apply_timeline_filters(query, account, local_only)

View File

@ -21,11 +21,12 @@ class FanOutOnWriteService < BaseService
deliver_to_lists(status) deliver_to_lists(status)
end 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) 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_public(status)
deliver_to_media(status) if status.media_attachments.any? deliver_to_media(status) if status.media_attachments.any?

View File

@ -72,6 +72,12 @@
.fields-group .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') = 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/ %hr.spacer/
.fields-group .fields-group

View File

@ -438,6 +438,12 @@ en:
show_known_fediverse_at_about_page: show_known_fediverse_at_about_page:
desc_html: When toggled, it will show toots from all the known fediverse on preview. Otherwise it will only show local toots. desc_html: When toggled, it will show toots from all the known fediverse on preview. Otherwise it will only show local toots.
title: Show known fediverse on timeline preview title: Show known fediverse on timeline preview
show_reblogs_in_public_timelines:
desc_html: Show public boosts of public toots in local and public timelines.
title: Show boosts in public timelines
show_replies_in_public_timelines:
desc_html: In addition to public self-replies (threads), show public replies in local and public timelines.
title: Show replies in public timelines
show_staff_badge: show_staff_badge:
desc_html: Show a staff badge on a user page desc_html: Show a staff badge on a user page
title: Show staff badge title: Show staff badge

View File

@ -62,6 +62,8 @@ defaults: &defaults
activity_api_enabled: true activity_api_enabled: true
peers_api_enabled: true peers_api_enabled: true
show_known_fediverse_at_about_page: true show_known_fediverse_at_about_page: true
show_reblogs_in_public_timelines: false
show_replies_in_public_timelines: false
development: development:
<<: *defaults <<: *defaults