about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/settings/preferences_controller.rb2
-rw-r--r--app/lib/feed_manager.rb22
-rw-r--r--app/lib/user_settings_decorator.rb5
-rw-r--r--app/models/user.rb5
-rw-r--r--app/views/settings/preferences/filters/show.html.haml3
-rw-r--r--config/locales/en-MP.yml13
-rw-r--r--config/locales/simple_form.en-MP.yml4
7 files changed, 41 insertions, 13 deletions
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb
index 9cb05ed7e..1bc66fb79 100644
--- a/app/controllers/settings/preferences_controller.rb
+++ b/app/controllers/settings/preferences_controller.rb
@@ -5,7 +5,6 @@ class Settings::PreferencesController < Settings::BaseController
 
   def update
     if user_settings.update(user_settings_params.to_h)
-      Rails.cache.delete("filter_settings:#{current_user.account_id}")
       ClearReblogsWorker.perform_async(current_user.account_id) if current_user.disables_home_reblogs?
     end
 
@@ -72,6 +71,7 @@ class Settings::PreferencesController < Settings::BaseController
       :setting_boost_every,
       :setting_boost_jitter,
       :setting_boost_random,
+      :setting_filter_unknown,
       :setting_unpublish_on_delete,
       :setting_rss_disabled,
       :setting_no_boosts_home,
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index 9d6550c0d..892af9655 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -39,9 +39,9 @@ class FeedManager
   def filter?(timeline_type, status, receiver)
     case timeline_type
     when :home
-      filter_from_home?(status, receiver.id, build_crutches(receiver.id, [status]))
+      filter_from_home?(status, receiver.id, build_crutches(receiver.id, [status]), receiver.user&.filters_unknown?)
     when :list
-      filter_from_list?(status, receiver) || filter_from_home?(status, receiver.account_id, build_crutches(receiver.account_id, [status]))
+      filter_from_list?(status, receiver) || filter_from_home?(status, receiver.account_id, build_crutches(receiver.account_id, [status]), receiver.user&.filters_unknown?)
     when :mentions
       filter_from_mentions?(status, receiver.id)
     when :direct
@@ -148,6 +148,7 @@ class FeedManager
     timeline_key = key(:home, into_account.id)
     aggregate    = into_account.user&.aggregates_reblogs?
     no_reblogs   = into_account.user&.disables_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)
 
     if redis.zcard(timeline_key) >= FeedManager::MAX_ITEMS / 4
@@ -159,7 +160,7 @@ class FeedManager
     crutches = build_crutches(into_account.id, statuses)
 
     statuses.each do |status|
-      next if filter_from_home?(status, into_account.id, crutches)
+      next if filter_from_home?(status, into_account.id, crutches, no_unknown)
 
       add_to_feed(:home, into_account.id, status, aggregate, no_reblogs)
     end
@@ -175,6 +176,7 @@ class FeedManager
     timeline_key = key(:list, list.id)
     aggregate    = list.account.user&.aggregates_reblogs?
     no_reblogs   = list.account.user&.disables_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)
 
     if redis.zcard(timeline_key) >= FeedManager::MAX_ITEMS / 4
@@ -186,7 +188,7 @@ class FeedManager
     crutches = build_crutches(list.account_id, statuses)
 
     statuses.each do |status|
-      next if filter_from_home?(status, list.account_id, crutches) || filter_from_list?(status, list)
+      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)
     end
@@ -276,7 +278,7 @@ class FeedManager
         crutches = build_crutches(account.id, statuses)
 
         statuses.each do |status|
-          next if filter_from_list?(status, account.id) || filter_from_home?(status, account.id, crutches)
+          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?)
         end
@@ -293,6 +295,7 @@ class FeedManager
     limit        = FeedManager::MAX_ITEMS / 2
     aggregate    = account.user&.aggregates_reblogs?
     no_reblogs   = account.user&.disables_home_reblogs?
+    no_unknown   = account.user&.filters_unknown?
     timeline_key = key(:home, account.id)
 
     account.statuses.limit(limit).each do |status|
@@ -314,7 +317,7 @@ class FeedManager
       crutches = build_crutches(account.id, statuses)
 
       statuses.each do |status|
-        next if filter_from_home?(status, account.id, crutches)
+        next if filter_from_home?(status, account.id, crutches, no_unknown)
 
         add_to_feed(:home, account.id, status, aggregate, no_reblogs, false)
       end
@@ -403,7 +406,7 @@ class FeedManager
   # @param [Integer] receiver_id
   # @param [Hash] crutches
   # @return [Boolean]
-  def filter_from_home?(status, receiver_id, crutches)
+  def filter_from_home?(status, receiver_id, crutches, followed_only = false)
     return false if receiver_id == status.account_id
     return true  if !status.published? || crutches[:hiding_thread][status.conversation_id]
     return true  if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?)
@@ -431,7 +434,7 @@ class FeedManager
       return !!should_filter
     elsif status.reblog? # ...it's a boost and...
       # ...you don't follow the OP and they're non-local or they're silenced...
-      should_filter = !(crutches[:local][status.reblog.account_id] || crutches[:following][status.reblog.account_id])
+      should_filter = followed_only && !crutches[:following][status.reblog.account_id]
 
       # ..or you're hiding boosts from them...
       should_filter ||= crutches[:hiding_reblogs][status.account_id]
@@ -561,7 +564,7 @@ class FeedManager
 
     if status.reblog?
       add_to_reblogs(account_id, status, aggregate_reblogs, stream) if timeline_type == :home
-      return false if skip_reblogs
+      return false if skip_reblogs || (timeline_type == :home && !status.reblog.local?)
     end
 
     if status.reblog? && (aggregate_reblogs.nil? || aggregate_reblogs)
@@ -666,7 +669,6 @@ class FeedManager
     crutches[:domain_blocking] = AccountDomainBlock.where(account_id: receiver_id, domain: statuses.map { |s| s.reblog&.account&.domain }.compact).pluck(:domain).each_with_object({}) { |domain, mapping| mapping[domain] = true }
     crutches[:blocked_by]      = Block.where(target_account_id: receiver_id, account_id: statuses.map { |s| s.reblog&.account_id }.compact).pluck(:account_id).each_with_object({}) { |id, mapping| mapping[id] = true }
     crutches[:hiding_thread]   = ConversationMute.where(account_id: receiver_id, conversation_id: statuses.map(&:conversation_id).compact).pluck(:conversation_id).each_with_object({}) { |id, mapping| mapping[id] = true }
-    crutches[:local]           = Account.local.where(id: participants, silenced_at: nil, suspended_at: nil).pluck(:id).each_with_object({}) { |id, mapping| mapping[id] = true }
 
     crutches
   end
diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb
index e5bc7276c..8bed47835 100644
--- a/app/lib/user_settings_decorator.rb
+++ b/app/lib/user_settings_decorator.rb
@@ -60,6 +60,7 @@ class UserSettingsDecorator
     user.settings['boost_every']         = boost_every_preference if change?('setting_boost_every')
     user.settings['boost_jitter']        = boost_jitter_preference if change?('setting_boost_jitter')
     user.settings['boost_random']        = boost_random_preference if change?('setting_boost_random')
+    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')
@@ -229,6 +230,10 @@ class UserSettingsDecorator
     boolean_cast_setting 'setting_boost_random'
   end
 
+  def filter_unknown_preference
+    boolean_cast_setting 'setting_filter_unknown'
+  end
+
   def unpublish_on_delete_preference
     boolean_cast_setting 'setting_unpublish_on_delete'
   end
diff --git a/app/models/user.rb b/app/models/user.rb
index 12c1e9650..f9a0df46f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -124,6 +124,7 @@ class User < ApplicationRecord
            :style_wide_media,
            :publish_in, :unpublish_in, :unpublish_delete, :boost_every, :boost_jitter,
            :boost_random, :unpublish_on_delete, :rss_disabled, :no_boosts_home,
+           :filter_unknown,
            to: :settings, prefix: :setting, allow_nil: false
 
   attr_reader :invite_code, :sign_in_token_attempt
@@ -266,6 +267,10 @@ class User < ApplicationRecord
     @disables_home_reblogs ||= settings.no_boosts_home
   end
 
+  def filters_unknown?
+    @filters_unknown ||= settings.filter_unknown
+  end
+
   # rubocop:disable Naming/MethodParameterName
   def token_for_app(a)
     return nil if a.nil? || a.owner != self
diff --git a/app/views/settings/preferences/filters/show.html.haml b/app/views/settings/preferences/filters/show.html.haml
index ae0993bc7..c30167cb5 100644
--- a/app/views/settings/preferences/filters/show.html.haml
+++ b/app/views/settings/preferences/filters/show.html.haml
@@ -12,6 +12,9 @@
   .fields-group
     = f.input :setting_no_boosts_home, as: :boolean, wrapper: :with_label
 
+  .fields-group
+    = f.input :setting_filter_unknown, as: :boolean, wrapper: :with_label
+
   %h4= t 'preferences.public_timelines'
 
   .fields-group
diff --git a/config/locales/en-MP.yml b/config/locales/en-MP.yml
index 481787c00..8b0c6d29b 100644
--- a/config/locales/en-MP.yml
+++ b/config/locales/en-MP.yml
@@ -99,6 +99,19 @@ en-MP:
   exports:
     archive_takeout:
       hint_html: You can request an archive of your <strong>roars and media</strong>. The exported data will be in the ActivityPub format, readable by any compliant software. You can request an archive every 7 days.
+  history:
+    '0': Never
+    1: 1 week
+    2: 2 weeks
+    3: 3 weeks
+    6: 6 weeks
+    12: 12 weeks
+    18: 18 weeks
+    24: 24 weeks
+    36: 36 weeks
+    52: 52 weeks
+    104: 104 weeks
+    156: 156 weeks
   notification_mailer:
     favourite:
       body: 'Your status was admired by %{name}:'
diff --git a/config/locales/simple_form.en-MP.yml b/config/locales/simple_form.en-MP.yml
index 65b62b9de..d8ff84775 100644
--- a/config/locales/simple_form.en-MP.yml
+++ b/config/locales/simple_form.en-MP.yml
@@ -26,7 +26,7 @@ en-MP:
         setting_default_content_type_console_html: <code>Plain-text console formatting.</code>
         setting_default_content_type_bbcode_html: "<strong>[b]Bold[/b]</strong>, <u>[u]Underline[/u]</u>, <em>[i]Italic[/i]</em>, <code>[code]Console[/code]</code>, ..."
         setting_default_language: The language of your roars can be detected automatically, but it's not always accurate
-        setting_filter_from_unknown: Do not show boosts from unfollowed accounts on your home timeline.  Takes effect for newly-pushed items.
+        setting_filter_unknown: Strictly filter unfollowed authors, including those of boosts, from your home and list timelines.  Takes effect for newly-pushed items.
         setting_no_boosts_home: Filters boosts from the home timeline, reguardless of the app you use.  These boosts will still be available in the Boosts list.
         setting_manual_publish: This allows you to draft, proofread, and edit your roars before publishing them.  You can publish a roar from its <strong>action menu</strong> (the three dots).
         setting_rss_disabled: Improves privacy by turning off your account's public RSS feed.
@@ -55,7 +55,7 @@ en-MP:
         setting_display_media_show_all: Reveal all
         setting_expand_spoilers: Always expand roars marked with content warnings
         setting_favourite_modal: Show confirmation dialog before admiring (applies to Glitch flavour only)
-        setting_filter_from_unknown: Filter boosts from unfollowed accounts
+        setting_filter_unknown: Filter unfollowed authors
         setting_manual_publish: Manually publish roars
         setting_no_boosts_home: Disable boosts in home timeline
         setting_publish_in: Auto-publish