mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-24 00:54:02 -05:00
Also filter notifications containing muted keywords.
This commit is contained in:
parent
9226257a1b
commit
d03b48cea0
@ -177,7 +177,7 @@ class FeedManager
|
|||||||
should_filter ||= matcher =~ status.reblog.spoiler_text
|
should_filter ||= matcher =~ status.reblog.spoiler_text
|
||||||
end
|
end
|
||||||
|
|
||||||
should_filter
|
!!should_filter
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_from_mentions?(status, receiver_id)
|
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 = 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 ||= (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
|
should_filter
|
||||||
end
|
end
|
||||||
|
@ -185,6 +185,13 @@ RSpec.describe FeedManager do
|
|||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
expect(FeedManager.instance.filter?(:mentions, status, bob.id)).to be false
|
expect(FeedManager.instance.filter?(:mentions, status, bob.id)).to be false
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user