mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-15 11:21:42 +00:00
Also run the keyword matcher on a status' tags. #208.
This commit is contained in:
parent
04508868b0
commit
431503bae2
|
@ -173,10 +173,14 @@ class FeedManager
|
||||||
def keyword_filter?(status, matcher)
|
def keyword_filter?(status, matcher)
|
||||||
should_filter = matcher =~ status.text
|
should_filter = matcher =~ status.text
|
||||||
should_filter ||= matcher =~ status.spoiler_text
|
should_filter ||= matcher =~ status.spoiler_text
|
||||||
|
should_filter ||= status.tags.find_each.any? { |t| matcher =~ t.name }
|
||||||
|
|
||||||
if status.reblog?
|
if status.reblog?
|
||||||
should_filter ||= matcher =~ status.reblog.text
|
reblog = status.reblog
|
||||||
should_filter ||= matcher =~ status.reblog.spoiler_text
|
|
||||||
|
should_filter ||= matcher =~ reblog.text
|
||||||
|
should_filter ||= matcher =~ reblog.spoiler_text
|
||||||
|
should_filter ||= reblog.tags.find_each.any? { |t| matcher =~ t.name }
|
||||||
end
|
end
|
||||||
|
|
||||||
!!should_filter
|
!!should_filter
|
||||||
|
|
|
@ -164,6 +164,22 @@ RSpec.describe FeedManager do
|
||||||
|
|
||||||
expect(FeedManager.instance.filter?(:home, reblog, alice.id)).to be true
|
expect(FeedManager.instance.filter?(:home, reblog, alice.id)).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns true for a status with a tag that matches a muted keyword' do
|
||||||
|
Fabricate('Glitch::KeywordMute', account: alice, keyword: 'jorts')
|
||||||
|
status = Fabricate(:status, account: bob)
|
||||||
|
status.tags << Fabricate(:tag, name: 'jorts')
|
||||||
|
|
||||||
|
expect(FeedManager.instance.filter?(:home, status, alice.id)).to be true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns true for a status with a tag that matches an octothorpe-prefixed muted keyword' do
|
||||||
|
Fabricate('Glitch::KeywordMute', account: alice, keyword: '#jorts')
|
||||||
|
status = Fabricate(:status, account: bob)
|
||||||
|
status.tags << Fabricate(:tag, name: 'jorts')
|
||||||
|
|
||||||
|
expect(FeedManager.instance.filter?(:home, status, alice.id)).to be true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for mentions feed' do
|
context 'for mentions feed' do
|
||||||
|
|
Loading…
Reference in a new issue