about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2017-10-22 00:23:21 -0500
committerDavid Yip <yipdw@member.fsf.org>2017-10-22 00:38:53 -0500
commit19826774f06244b0c84a1973b3a366df0d7f0f5a (patch)
tree3aa464c961df3a7fe820f7acf841ac9d9f33c518 /app
parentad86c86fa8e0d577b1a6c7411367420e6beea4ea (diff)
keyword mutes: also check spoiler (CW) text and reblogged statuses.
Diffstat (limited to 'app')
-rw-r--r--app/lib/feed_manager.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index 576188324..e0a257cd0 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -138,13 +138,11 @@ class FeedManager
   end
 
   def filter_from_home?(status, receiver_id)
-    keyword_mute_matcher = Glitch::KeywordMute.matcher_for(receiver_id)
-
-    return true if keyword_mute_matcher =~ status.text
-
     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 keyword_filter?(status, Glitch::KeywordMute.matcher_for(receiver_id))
+
     check_for_mutes = [status.account_id]
     check_for_mutes.concat(status.mentions.pluck(:account_id))
     check_for_mutes.concat([status.reblog.account_id]) if status.reblog?
@@ -163,7 +161,6 @@ class FeedManager
       return should_filter
     elsif status.reblog?                                                                                                 # Filter out a reblog
       should_filter   = Block.where(account_id: status.reblog.account_id, target_account_id: receiver_id).exists?        # or if the author of the reblogged status is blocking me
-      should_filter ||= keyword_mute_matcher.matches?(status.reblog.text)
       should_filter ||= AccountDomainBlock.where(account_id: receiver_id, domain: status.reblog.account.domain).exists?  # or the author's domain is blocked
       return should_filter
     end
@@ -171,6 +168,18 @@ class FeedManager
     false
   end
 
+  def keyword_filter?(status, matcher)
+    should_filter   = matcher =~ status.text
+    should_filter ||= matcher =~ status.spoiler_text
+
+    if status.reblog?
+      should_filter ||= matcher =~ status.reblog.text
+      should_filter ||= matcher =~ status.reblog.spoiler_text
+    end
+
+    should_filter
+  end
+
   def filter_from_mentions?(status, receiver_id)
     return true if receiver_id == status.account_id