]> cat aescling's git repositories - mastodon.git/commitdiff
Add site-wide options to show reblogs and replies in local/public timelines
authorThibaut Girka <thib@sitedethib.com>
Tue, 30 Apr 2019 19:51:24 +0000 (21:51 +0200)
committerThibG <thib@sitedethib.com>
Wed, 1 May 2019 20:33:09 +0000 (22:33 +0200)
Fixes #1021

app/models/form/admin_settings.rb
app/models/status.rb
app/services/fan_out_on_write_service.rb
app/views/admin/settings/edit.html.haml
config/locales/en.yml
config/settings.yml

index f81776346d04d49e6c1a31eeb13b25c9fddda9df..0e9bfb265ed17f3efa7d3e04e7db333fbf0db5bc 100644 (file)
@@ -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(
index e7fa0220b6fca8172858f406927ec1d9454995e4..1b905d5b89b2a6dd322aefa644f9d80175f6a022 100644 (file)
@@ -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)
index de7c031d8dd988665cb16a45217237669fd2e741..b66dc342e5b41b2e8543b617c2c65cb566c3a2c7 100644 (file)
@@ -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?
index 8f7acde5fd0cf925788a59a8be8fda5fb55bb76a..a8c9f6a583c5c43d8ec64aa846d11b453fb87ffd 100644 (file)
   .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
index 5ec70a675f16bc5369dd9bc7755589c0890d0a9a..20a75e60ce731cb46452d5ca9aa9aef004210e68 100644 (file)
@@ -438,6 +438,12 @@ en:
       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.
         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:
         desc_html: Show a staff badge on a user page
         title: Show staff badge
index f0bfa9b69b236b49eb0fba0472d6935958dfd3ee..c3aeab5512799ef45d8b49e0244fa9bcd596fccc 100644 (file)
@@ -62,6 +62,8 @@ defaults: &defaults
   activity_api_enabled: true
   peers_api_enabled: true
   show_known_fediverse_at_about_page: true
+  show_reblogs_in_public_timelines: false
+  show_replies_in_public_timelines: false
 
 development:
   <<: *defaults