about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2017-10-21 15:44:47 -0500
committerDavid Yip <yipdw@member.fsf.org>2017-10-21 15:44:47 -0500
commitad86c86fa8e0d577b1a6c7411367420e6beea4ea (patch)
treee0be0cb0ca1e454b8e3cd73d6471163018e6efc0 /app
parent670e6a33f8eeca628707dc020e02ce32502d74a4 (diff)
Apply keyword mutes to reblogs.
Diffstat (limited to 'app')
-rw-r--r--app/lib/feed_manager.rb5
-rw-r--r--app/models/glitch/keyword_mute.rb4
2 files changed, 8 insertions, 1 deletions
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index 1123f88bb..576188324 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -138,7 +138,9 @@ class FeedManager
   end
 
   def filter_from_home?(status, receiver_id)
-    return true if Glitch::KeywordMute.matcher_for(receiver_id) =~ status.text
+    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?)
@@ -161,6 +163,7 @@ 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
diff --git a/app/models/glitch/keyword_mute.rb b/app/models/glitch/keyword_mute.rb
index 3b0b47f52..823e252d3 100644
--- a/app/models/glitch/keyword_mute.rb
+++ b/app/models/glitch/keyword_mute.rb
@@ -45,5 +45,9 @@ class Glitch::KeywordMute < ApplicationRecord
     def =~(str)
       regex ? regex =~ str : false
     end
+
+    def matches?(str)
+      !!(regex =~ str)
+    end
   end
 end