about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-12-07 22:13:32 -0600
committermultiple creatures <dev@multiple-creature.party>2019-12-07 22:13:32 -0600
commit6fa9c3eb1bb416bdc05f8bd4011de396e6248aa5 (patch)
treebed741486425885e22caa0d1fb44872227b67615 /app/lib
parentfeceb543fd6df602c8c117247488e415ef89b78a (diff)
add option to toggle whether regex filters should be applied to mentions
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/feed_manager.rb11
-rw-r--r--app/lib/user_settings_decorator.rb6
2 files changed, 13 insertions, 4 deletions
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