about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-10-21 01:50:04 -0500
committerFire Demon <firedemon@creature.cafe>2020-10-21 01:50:04 -0500
commit0a32c484e1b8819983514f6f06da30c910cdd133 (patch)
tree48457fb5e94b1b47aeeb0c1d92758e58889b9fe9 /app
parent0e6cb59f2f51ad6831188b47fd9e5c6827e9ff91 (diff)
Make receiving boosts from Tavern timeline in home feed opt-in; always aggregate boosts
Diffstat (limited to 'app')
-rw-r--r--app/controllers/settings/preferences_controller.rb7
-rw-r--r--app/javascript/mastodon/locales/en-MP.json2
-rw-r--r--app/lib/feed_manager.rb62
-rw-r--r--app/lib/user_settings_decorator.rb11
-rw-r--r--app/models/user.rb12
-rw-r--r--app/views/settings/preferences/appearance/show.html.haml3
-rw-r--r--app/views/settings/preferences/filters/show.html.haml2
7 files changed, 43 insertions, 56 deletions
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb
index 12c03ce76..0a7c53f83 100644
--- a/app/controllers/settings/preferences_controller.rb
+++ b/app/controllers/settings/preferences_controller.rb
@@ -4,8 +4,10 @@ class Settings::PreferencesController < Settings::BaseController
   def show; end
 
   def update
+    old_home_reblogs = current_user.home_reblogs?
+  
     if user_settings.update(user_settings_params.to_h)
-      ClearReblogsWorker.perform_async(current_user.account_id) if current_user.disables_home_reblogs?
+      ClearReblogsWorker.perform_async(current_user.account_id) unless old_home_reblogs == current_user.home_reblogs? || current_user.home_reblogs?
     end
 
     if current_user.update(user_params)
@@ -51,7 +53,6 @@ class Settings::PreferencesController < Settings::BaseController
       :setting_noindex,
       :setting_hide_network,
       :setting_hide_followers_count,
-      :setting_aggregate_reblogs,
       :setting_show_application,
       :setting_advanced_layout,
       :setting_default_content_type,
@@ -74,7 +75,7 @@ class Settings::PreferencesController < Settings::BaseController
       :setting_filter_unknown,
       :setting_unpublish_on_delete,
       :setting_rss_disabled,
-      :setting_no_boosts_home,
+      :setting_home_reblogs,
       :setting_max_history_public,
       :setting_max_history_private,
       notification_emails: %i(follow follow_request reblog favourite mention digest report pending_account trending_tag),
diff --git a/app/javascript/mastodon/locales/en-MP.json b/app/javascript/mastodon/locales/en-MP.json
index ca175119e..88a0087b6 100644
--- a/app/javascript/mastodon/locales/en-MP.json
+++ b/app/javascript/mastodon/locales/en-MP.json
@@ -24,7 +24,7 @@
   "column.public": "Fediverse",
   "column.toot": "Roars & Growls",
   "community.column_settings.local_only": "Monsterpit only",
-  "community.column_settings.remote_only": "Rowdy tavern mode",
+  "community.column_settings.remote_only": "Rowdy Tavern mode",
   "compose_form.clear": "Double-click to clear",
   "compose_form.direct_message_warning": "This roar will only be sent to the mentioned creatures.",
   "compose_form.hashtag_warning": "This roar won't be listed under any hashtag as it is unlisted. Only public roars can be searched by hashtag.",
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index 8228dc943..f3b07c3e0 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -56,7 +56,7 @@ class FeedManager
   # @param [Status] status
   # @return [Boolean]
   def push_to_home(account, status)
-    return false unless add_to_feed(:home, account.id, status, account.user&.aggregates_reblogs?, account.user&.disables_home_reblogs?)
+    return false unless add_to_feed(:home, account.id, status, account.user&.home_reblogs?)
 
     trim(:home, account.id)
     PushUpdateWorker.perform_async(account.id, status.id, "timeline:#{account.id}") if push_update_required?("timeline:#{account.id}")
@@ -68,7 +68,7 @@ class FeedManager
   # @param [Status] status
   # @return [Boolean]
   def unpush_from_home(account, status, include_reblogs_list = true)
-    return false unless remove_from_feed(:home, account.id, status, account.user&.aggregates_reblogs?, include_reblogs_list)
+    return false unless remove_from_feed(:home, account.id, status, include_reblogs_list)
 
     redis.publish("timeline:#{account.id}", Oj.dump(event: :delete, payload: status.id.to_s))
     true
@@ -80,7 +80,7 @@ class FeedManager
   # @return [Boolean]
   def push_to_list(list, status)
     return false if filter_from_list?(status, list)
-    return false unless add_to_feed(:list, list.id, status, list.account.user&.aggregates_reblogs?, !list.reblogs?)
+    return false unless add_to_feed(:list, list.id, status, list.reblogs?)
 
     trim(:list, list.id)
     PushUpdateWorker.perform_async(list.account_id, status.id, "timeline:list:#{list.id}") if push_update_required?("timeline:list:#{list.id}")
@@ -92,7 +92,7 @@ class FeedManager
   # @param [Status] status
   # @return [Boolean]
   def unpush_from_list(list, status)
-    return false unless remove_from_feed(:list, list.id, status, list.account.user&.aggregates_reblogs?)
+    return false unless remove_from_feed(:list, list.id, status)
 
     redis.publish("timeline:list:#{list.id}", Oj.dump(event: :delete, payload: status.id.to_s))
     true
@@ -146,8 +146,7 @@ class FeedManager
   # @return [void]
   def merge_into_home(from_account, into_account)
     timeline_key = key(:home, into_account.id)
-    aggregate    = into_account.user&.aggregates_reblogs?
-    no_reblogs   = into_account.user&.disables_home_reblogs?
+    reblogs      = into_account.user&.home_reblogs?
     no_unknown   = into_account.user&.filters_unknown?
     query        = from_account.statuses.where(visibility: [:public, :unlisted, :private]).includes(:preloadable_poll, reblog: :account).limit(FeedManager::MAX_ITEMS / 4)
 
@@ -162,7 +161,7 @@ class FeedManager
     statuses.each do |status|
       next if filter_from_home?(status, into_account.id, crutches, no_unknown)
 
-      add_to_feed(:home, into_account.id, status, aggregate, no_reblogs)
+      add_to_feed(:home, into_account.id, status, reblogs)
     end
 
     trim(:home, into_account.id)
@@ -174,8 +173,7 @@ class FeedManager
   # @return [void]
   def merge_into_list(from_account, list)
     timeline_key = key(:list, list.id)
-    aggregate    = list.account.user&.aggregates_reblogs?
-    no_reblogs   = list.account.user&.disables_home_reblogs?
+    reblogs      = list.account.user&.home_reblogs?
     no_unknown   = list.account.user&.filters_unknown?
     query        = from_account.statuses.where(visibility: [:public, :unlisted, :private]).includes(:preloadable_poll, reblog: :account).limit(FeedManager::MAX_ITEMS / 4)
 
@@ -190,7 +188,7 @@ class FeedManager
     statuses.each do |status|
       next if filter_from_home?(status, list.account_id, crutches, no_unknown) || filter_from_list?(status, list)
 
-      add_to_feed(:list, list.id, status, aggregate, no_reblogs)
+      add_to_feed(:list, list.id, status, reblogs)
     end
 
     trim(:list, list.id)
@@ -205,7 +203,7 @@ class FeedManager
     oldest_home_score = redis.zrange(timeline_key, 0, 0, with_scores: true)&.first&.last&.to_i || 0
 
     from_account.statuses.select('id, reblog_of_id').where('id > ?', oldest_home_score).reorder(nil).find_each do |status|
-      remove_from_feed(:home, into_account.id, status, into_account.user&.aggregates_reblogs?)
+      remove_from_feed(:home, into_account.id, status)
     end
   end
 
@@ -218,7 +216,7 @@ class FeedManager
     oldest_list_score = redis.zrange(timeline_key, 0, 0, with_scores: true)&.first&.last&.to_i || 0
 
     from_account.statuses.select('id, reblog_of_id').where('id > ?', oldest_list_score).reorder(nil).find_each do |status|
-      remove_from_feed(:list, list.id, status, list.account.user&.aggregates_reblogs?, !list.reblogs?)
+      remove_from_feed(:list, list.id, status, !list.reblogs?)
     end
   end
 
@@ -249,7 +247,7 @@ class FeedManager
     timeline_key        = key(:home, account.id)
     timeline_status_ids = redis.zrange(timeline_key, 0, -1)
 
-    Status.reblogs.where(id: timeline_status_ids).find_each do |status|
+    Status.reblogs.joins(:reblog).where(reblogs_statuses: { local: false }).where(id: timeline_status_ids).find_each do |status|
       unpush_from_home(account, status, false)
     end
   end
@@ -280,7 +278,7 @@ class FeedManager
         statuses.each do |status|
           next if filter_from_list?(status, account.id) || filter_from_home?(status, account.id, crutches, account.user&.filters_unknown?)
 
-          add_to_feed(:list, list.id, status, list.account.user&.aggregates_reblogs?, !list.reblogs?)
+          add_to_feed(:list, list.id, status, list.reblogs?)
         end
 
         trim(:list, list.id)
@@ -293,13 +291,12 @@ class FeedManager
   # @return [void]
   def populate_home(account)
     limit        = FeedManager::MAX_ITEMS / 2
-    aggregate    = account.user&.aggregates_reblogs?
-    no_reblogs   = account.user&.disables_home_reblogs?
+    reblogs      = account.user&.home_reblogs?
     no_unknown   = account.user&.filters_unknown?
     timeline_key = key(:home, account.id)
 
     account.statuses.limit(limit).each do |status|
-      add_to_feed(:home, account.id, status, aggregate, no_reblogs)
+      add_to_feed(:home, account.id, status, reblogs)
     end
 
     account.following.includes(:account_stat).find_each do |target_account|
@@ -319,7 +316,7 @@ class FeedManager
       statuses.each do |status|
         next if filter_from_home?(status, account.id, crutches, no_unknown)
 
-        add_to_feed(:home, account.id, status, aggregate, no_reblogs, false)
+        add_to_feed(:home, account.id, status, reblogs, false)
       end
 
       trim(:home, account.id)
@@ -556,18 +553,19 @@ class FeedManager
   # @param [Symbol] timeline_type
   # @param [Integer] account_id
   # @param [Status] status
-  # @param [Boolean] aggregate_reblogs
+  # @param [Boolean] home_reblogs
+  # @param [Boolean] stream
   # @return [Boolean]
-  def add_to_feed(timeline_type, account_id, status, aggregate_reblogs = true, skip_reblogs = false, stream = true)
+  def add_to_feed(timeline_type, account_id, status, home_reblogs = true, stream = true)
     timeline_key = key(timeline_type, account_id)
     reblog_key   = key(timeline_type, account_id, 'reblogs')
 
     if status.reblog?
-      add_to_reblogs(account_id, status, aggregate_reblogs, stream) if timeline_type == :home
-      return false if skip_reblogs || (timeline_type == :home && !status.reblog.local?)
+      add_to_reblogs(account_id, status, stream) if timeline_type == :home
+      return false unless home_reblogs || (timeline_type == :home && status.reblog.local?)
     end
 
-    if status.reblog? && (aggregate_reblogs.nil? || aggregate_reblogs)
+    if status.reblog?
       # If the original status or a reblog of it is within
       # REBLOG_FALLOFF statuses from the top, do not re-insert it into
       # the feed
@@ -599,7 +597,7 @@ class FeedManager
       redis.zadd(timeline_key, status.id, status.id)
     end
 
-    add_to_reblogs(account_id, status, aggregate_reblogs, stream) if timeline_type == :home && status.reblog?
+    add_to_reblogs(account_id, status, stream) if timeline_type == :home && status.reblog?
 
     true
   end
@@ -611,15 +609,15 @@ class FeedManager
   # @param [Symbol] timeline_type
   # @param [Integer] account_id
   # @param [Status] status
-  # @param [Boolean] aggregate_reblogs
+  # @param [Boolean] include_reblogs_list
   # @return [Boolean]
-  def remove_from_feed(timeline_type, account_id, status, aggregate_reblogs = true, include_reblogs_list = true)
+  def remove_from_feed(timeline_type, account_id, status, include_reblogs_list = true)
     timeline_key = key(timeline_type, account_id)
     reblog_key   = key(timeline_type, account_id, 'reblogs')
 
-    remove_from_reblogs(account_id, status, aggregate_reblogs) if include_reblogs_list && timeline_type == :home && status.reblog?
+    remove_from_reblogs(account_id, status) if include_reblogs_list && timeline_type == :home && status.reblog?
 
-    if status.reblog? && (aggregate_reblogs.nil? || aggregate_reblogs)
+    if status.reblog?
       # 1. If the reblogging status is not in the feed, stop.
       status_rank = redis.zrevrank(timeline_key, status.id)
       return false if status_rank.nil?
@@ -680,9 +678,9 @@ class FeedManager
     end
   end
 
-  def add_to_reblogs(account_id, status, aggregate_reblogs = true, stream = true)
+  def add_to_reblogs(account_id, status, stream = true)
     reblogs_list_id = find_or_create_reblogs_list(account_id).id
-    return unless add_to_feed(:list, reblogs_list_id, status, aggregate_reblogs)
+    return unless add_to_feed(:list, reblogs_list_id, status)
 
     trim(:list, reblogs_list_id)
     return unless stream && push_update_required?("timeline:list:#{reblogs_list_id}")
@@ -690,9 +688,9 @@ class FeedManager
     PushUpdateWorker.perform_async(account_id, status.id, "timeline:list:#{reblogs_list_id}")
   end
 
-  def remove_from_reblogs(account_id, status, aggregate_reblogs)
+  def remove_from_reblogs(account_id, status)
     reblogs_list_id = find_or_create_reblogs_list(account_id).id
-    return unless remove_from_feed(:list, reblogs_list_id, status, aggregate_reblogs)
+    return unless remove_from_feed(:list, reblogs_list_id, status)
 
     redis.publish("timeline:list:#{reblogs_list_id}", Oj.dump(event: :delete, payload: status.id.to_s))
   end
diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb
index ddce9764a..8d1af705a 100644
--- a/app/lib/user_settings_decorator.rb
+++ b/app/lib/user_settings_decorator.rb
@@ -39,7 +39,6 @@ class UserSettingsDecorator
     user.settings['flavour']             = flavour_preference if change?('setting_flavour')
     user.settings['skin']                = skin_preference if change?('setting_skin')
     user.settings['hide_network']        = hide_network_preference if change?('setting_hide_network')
-    user.settings['aggregate_reblogs']   = aggregate_reblogs_preference if change?('setting_aggregate_reblogs')
     user.settings['show_application']    = show_application_preference if change?('setting_show_application')
     user.settings['advanced_layout']     = advanced_layout_preference if change?('setting_advanced_layout')
     user.settings['default_content_type'] = default_content_type_preference if change?('setting_default_content_type')
@@ -63,7 +62,7 @@ class UserSettingsDecorator
     user.settings['filter_unknown']      = filter_unknown_preference if change?('setting_filter_unknown')
     user.settings['unpublish_on_delete'] = unpublish_on_delete_preference if change?('setting_unpublish_on_delete')
     user.settings['rss_disabled']        = rss_disabled_preference if change?('setting_rss_disabled')
-    user.settings['no_boosts_home']      = no_boosts_home_preference if change?('setting_no_boosts_home')
+    user.settings['home_reblogs']        = home_reblogs_preference if change?('setting_home_reblogs')
     user.settings['max_history_public']  = max_history_public_preference if change?('setting_max_history_public')
     user.settings['max_history_private'] = max_history_private_preference if change?('setting_max_history_private')
   end
@@ -152,10 +151,6 @@ class UserSettingsDecorator
     settings['setting_default_language']
   end
 
-  def aggregate_reblogs_preference
-    boolean_cast_setting 'setting_aggregate_reblogs'
-  end
-
   def advanced_layout_preference
     boolean_cast_setting 'setting_advanced_layout'
   end
@@ -244,8 +239,8 @@ class UserSettingsDecorator
     boolean_cast_setting 'setting_rss_disabled'
   end
 
-  def no_boosts_home_preference
-    boolean_cast_setting 'setting_no_boosts_home'
+  def home_reblogs_preference
+    boolean_cast_setting 'setting_home_reblogs'
   end
 
   def max_history_public_preference
diff --git a/app/models/user.rb b/app/models/user.rb
index c494aa7a5..afe248f57 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -116,14 +116,14 @@ class User < ApplicationRecord
 
   delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :favourite_modal, :delete_modal,
            :reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network, :hide_followers_count,
-           :expand_spoilers, :default_language, :aggregate_reblogs, :show_application,
+           :expand_spoilers, :default_language, :show_application,
            :advanced_layout, :use_blurhash, :use_pending_items, :trends, :crop_images,
            :default_content_type, :system_emoji_font,
            :manual_publish, :style_dashed_nest, :style_underline_a, :style_css_profile,
            :style_css_profile_errors, :style_css_webapp, :style_css_webapp_errors,
            :style_wide_media,
            :publish_in, :unpublish_in, :unpublish_delete, :boost_every, :boost_jitter,
-           :boost_random, :unpublish_on_delete, :rss_disabled, :no_boosts_home,
+           :boost_random, :unpublish_on_delete, :rss_disabled, :home_reblogs,
            :filter_unknown, :max_history_public, :max_history_private,
            to: :settings, prefix: :setting, allow_nil: false
 
@@ -255,16 +255,12 @@ class User < ApplicationRecord
     @hides_network ||= settings.hide_network
   end
 
-  def aggregates_reblogs?
-    @aggregates_reblogs ||= settings.aggregate_reblogs
-  end
-
   def shows_application?
     @shows_application ||= settings.show_application
   end
 
-  def disables_home_reblogs?
-    @disables_home_reblogs ||= settings.no_boosts_home
+  def home_reblogs?
+    @home_reblogs ||= settings.home_reblogs
   end
 
   def filters_unknown?
diff --git a/app/views/settings/preferences/appearance/show.html.haml b/app/views/settings/preferences/appearance/show.html.haml
index 87e7b91c5..48031a973 100644
--- a/app/views/settings/preferences/appearance/show.html.haml
+++ b/app/views/settings/preferences/appearance/show.html.haml
@@ -17,9 +17,6 @@
   %p.hint= t 'appearance.advanced_web_interface_hint'
 
   .fields-group
-    = f.input :setting_aggregate_reblogs, as: :boolean, wrapper: :with_label, recommended: true
-
-  .fields-group
     = f.input :setting_advanced_layout, as: :boolean, wrapper: :with_label, hint: false
 
   %h4= t 'appearance.animations_and_accessibility'
diff --git a/app/views/settings/preferences/filters/show.html.haml b/app/views/settings/preferences/filters/show.html.haml
index c30167cb5..17fa4c4a6 100644
--- a/app/views/settings/preferences/filters/show.html.haml
+++ b/app/views/settings/preferences/filters/show.html.haml
@@ -10,7 +10,7 @@
   %h4= t 'preferences.filtering'
 
   .fields-group
-    = f.input :setting_no_boosts_home, as: :boolean, wrapper: :with_label
+    = f.input :setting_home_reblogs, as: :boolean, wrapper: :with_label
 
   .fields-group
     = f.input :setting_filter_unknown, as: :boolean, wrapper: :with_label