Browse Source

Also filter notifications containing muted keywords.

closed-social-glitch-2
David Yip 7 years ago
parent
commit
d03b48cea0
2 changed files with 9 additions and 1 deletions
  1. +2
    -1
      app/lib/feed_manager.rb
  2. +7
    -0
      spec/lib/feed_manager_spec.rb

+ 2
- 1
app/lib/feed_manager.rb View 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

+ 7
- 0
spec/lib/feed_manager_spec.rb View 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

Loading…
Cancel
Save