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.rb11
-rw-r--r--app/lib/user_settings_decorator.rb6
-rw-r--r--app/models/account.rb2
-rw-r--r--app/models/user.rb6
-rwxr-xr-xapp/views/layouts/application.html.haml7
-rw-r--r--app/views/settings/preferences/show.html.haml2
-rw-r--r--config/locales/simple_form.en.yml2
8 files changed, 20 insertions, 18 deletions
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb
index 216fea636..09380efd9 100644
--- a/app/controllers/settings/preferences_controller.rb
+++ b/app/controllers/settings/preferences_controller.rb
@@ -42,7 +42,7 @@ class Settings::PreferencesController < Settings::BaseController
       :setting_larger_buttons,
       :setting_larger_drawer,
       :setting_larger_emoji,
-      :setting_remove_filtered,
+      :setting_filter_mentions,
       :setting_hide_replies_muted,
       :setting_hide_replies_blocked,
       :setting_hide_replies_blocker,
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index b2f040811..68e4df4ef 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -155,6 +155,15 @@ class FeedManager
   end
 
   def filter_from_home?(status, receiver_id)
+    return true if redis.sismember("filtered_statuses:#{receiver_id}", status.id)
+    if _filter_from_home?(status, receiver_id)
+      redis.sadd("filtered_statuses:#{receiver_id}", status.id)
+      return true
+    end
+    false
+  end
+
+  def _filter_from_home?(status, receiver_id)
     return false if receiver_id == status.account_id
     return true  if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?)
     return true  if phrase_filtered?(status, receiver_id)
@@ -187,7 +196,7 @@ class FeedManager
 
   def filter_from_mentions?(status, receiver_id)
     return true if receiver_id == status.account_id
-    return true if phrase_filtered?(status, receiver_id)
+    return true if Account.find(receiver_id)&.user&.filters_mentions? && phrase_filtered?(status, receiver_id)
 
     # This filter is called from NotifyService, but already after the sender of
     # the notification has been checked for mute/block. Therefore, it's not
diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb
index 3dcdccab5..c2fe58b2d 100644
--- a/app/lib/user_settings_decorator.rb
+++ b/app/lib/user_settings_decorator.rb
@@ -22,7 +22,7 @@ class UserSettingsDecorator
     user.settings['larger_menus']        = larger_menus_preference if change?('setting_larger_menus')
     user.settings['larger_buttons']      = larger_buttons_preference if change?('setting_larger_buttons')
     user.settings['larger_drawer']       = larger_drawer_preference if change?('setting_larger_drawer')
-    user.settings['remove_filtered']     = remove_filtered_preference if change?('setting_remove_filtered')
+    user.settings['filter_mentions']     = filter_mentions_preference if change?('setting_filter_mentions')
     user.settings['hide_replies_muted']  = hide_replies_muted_preference if change?('setting_hide_replies_muted')
     user.settings['hide_replies_blocked']= hide_replies_blocked_preference if change?('setting_hide_replies_blocked')
     user.settings['hide_replies_blocker']= hide_replies_blocker_preference if change?('setting_hide_replies_blocker')
@@ -88,8 +88,8 @@ class UserSettingsDecorator
     boolean_cast_setting 'setting_larger_emoji'
   end
 
-  def remove_filtered_preference
-    boolean_cast_setting 'setting_remove_filtered'
+  def filter_mentions_preference
+    boolean_cast_setting 'setting_filter_mentions'
   end
 
   def hide_replies_muted_preference
diff --git a/app/models/account.rb b/app/models/account.rb
index 6841fba3a..c52f28d33 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -144,6 +144,7 @@ class Account < ApplicationRecord
            :hides_stats?,
            :shows_application?,
 
+           :filters_mentions?,
            :hides_replies_of_muted?,
            :hides_replies_of_blocked?,
            :hides_replies_of_blocker?,
@@ -156,7 +157,6 @@ class Account < ApplicationRecord
            :wants_larger_buttons?,
            :wants_larger_drawer?,
            :wants_larger_emoji?,
-           :hides_filtered_gap?,
            :hides_mascot?,
            :hides_captions?,
            :shows_cursor?,
diff --git a/app/models/user.rb b/app/models/user.rb
index d0711c634..06af06911 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -122,7 +122,7 @@ class User < ApplicationRecord
     :larger_buttons,
     :larger_drawer,
     :larger_emoji,
-    :remove_filtered,
+    :filter_mentions,
     :hide_replies_muted,
     :hide_replies_blocked,
     :hide_replies_blocker,
@@ -268,8 +268,8 @@ class User < ApplicationRecord
     @wants_larger_emoji ||= (settings.larger_emoji || false)
   end
 
-  def hides_filtered_gap?
-    @hides_filtered_gap ||= (settings.remove_filtered || false)
+  def filters_mentions?
+    @filters_mentions ||= (settings.filter_mentions || false)
   end
 
   def hides_replies_of_muted?
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index 496c2eb5a..985e54683 100755
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -68,13 +68,6 @@
       :css
         .drawer { min-width: 400px !important }
 
-    - if current_account&.user_hides_filtered_gap?
-      :css
-        .status__wrapper--filtered {
-          height: 1px !important;
-          max-height: 1px !important;
-        }
-
     - if current_account&.user_hides_mascot?
       :css
         .drawer__inner__mastodon>img { display: none !important }
diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml
index 80ecf6d40..bde3dcf23 100644
--- a/app/views/settings/preferences/show.html.haml
+++ b/app/views/settings/preferences/show.html.haml
@@ -84,7 +84,7 @@
 
   .fields-group
     = f.input :setting_hide_mascot, as: :boolean, wrapper: :with_label
-    = f.input :setting_remove_filtered, as: :boolean, wrapper: :with_label
+    = f.input :setting_filter_mentions, as: :boolean, wrapper: :with_label
     = f.input :setting_hide_replies_muted, as: :boolean, wrapper: :with_label
     = f.input :setting_hide_replies_blocked, as: :boolean, wrapper: :with_label
     = f.input :setting_hide_replies_blocker, as: :boolean, wrapper: :with_label
diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml
index f039f6193..14c90c0ec 100644
--- a/config/locales/simple_form.en.yml
+++ b/config/locales/simple_form.en.yml
@@ -146,7 +146,7 @@ en:
         setting_larger_buttons: Increase size and spacing of action buttons
         setting_larger_drawer: Increase width of compose drawer column
         setting_larger_emoji: Increase size of emoji
-        setting_remove_filtered: Don't show placeholder gap for filtered roars
+        setting_filter_mentions: Apply regex filters to mentions
         setting_hide_replies_muted: Filter replies to those who you are muting
         setting_hide_replies_blocked: Filter replies to those who you are blocking
         setting_hide_replies_blocker: Filter replies to those who are blocking you