]> cat aescling's git repositories - mastodon.git/commitdiff
Also filter notifications containing muted keywords.
authorDavid Yip <yipdw@member.fsf.org>
Tue, 24 Oct 2017 23:51:27 +0000 (18:51 -0500)
committerDavid Yip <yipdw@member.fsf.org>
Tue, 24 Oct 2017 23:51:27 +0000 (18:51 -0500)
app/lib/feed_manager.rb
spec/lib/feed_manager_spec.rb

index e0a257cd07cdb7f5e0e26b9078ec49e216c2cbc2..2ddfac33661520e7b0796a8d678812cfd60e2abe 100644 (file)
@@ -177,7 +177,7 @@ class FeedManager
       should_filter ||= matcher =~ status.reblog.spoiler_text
     end
 
-    should_filter
+    !!should_filter
   end
 
   def filter_from_mentions?(status, receiver_id)
@@ -189,6 +189,7 @@ class FeedManager
 
     should_filter   = Block.where(account_id: receiver_id, target_account_id: check_for_blocks).any?                                     # Filter if it's from someone I blocked, in reply to someone I blocked, or mentioning someone I blocked
     should_filter ||= (status.account.silenced? && !Follow.where(account_id: receiver_id, target_account_id: status.account_id).exists?) # of if the account is silenced and I'm not following them
+    should_filter ||= keyword_filter?(status, Glitch::KeywordMute.matcher_for(receiver_id))                                              # or if the mention contains a muted keyword
 
     should_filter
   end
index 23ce373f2458404e30edad567d93624ce6e17ca5..e678d3ca4a318ec948fc1e54536cd8f88af63706 100644 (file)
@@ -185,6 +185,13 @@ RSpec.describe FeedManager do
         bob.follow!(alice)
         expect(FeedManager.instance.filter?(:mentions, status, bob.id)).to be false
       end
+
+      it 'returns true for status that contains a muted keyword' do
+        Fabricate('Glitch::KeywordMute', account: bob, keyword: 'take')
+        status = Fabricate(:status, text: 'This is a hot take', account: alice)
+        bob.follow!(alice)
+        expect(FeedManager.instance.filter?(:mentions, status, bob.id)).to be true
+      end
     end
   end
 
This page took 0.030807 seconds and 3 git commands to generate.