Migrate glitch-soc keyword mutes to Mastodon's

Completely remove glitch-soc's Keyword Mutes, migrate
existing database records to CustomFilters.

Handling of client-side filters is still not implemented
in the glitch-soc front-end.
This commit is contained in:
Thibaut Girka
2018-07-07 21:40:49 +02:00
parent ee41947e9d
commit 402da8065c
14 changed files with 55 additions and 565 deletions

View File

@ -134,68 +134,6 @@ RSpec.describe FeedManager do
expect(FeedManager.instance.filter?(:home, reblog, alice.id)).to be true
end
it 'returns true for a status containing a muted keyword' do
Fabricate('Glitch::KeywordMute', account: alice, keyword: 'take')
status = Fabricate(:status, text: 'This is a hot take', account: bob)
expect(FeedManager.instance.filter?(:home, status, alice.id)).to be true
end
it 'returns true for a reply containing a muted keyword' do
Fabricate('Glitch::KeywordMute', account: alice, keyword: 'take')
s1 = Fabricate(:status, text: 'Something', account: alice)
s2 = Fabricate(:status, text: 'This is a hot take', thread: s1, account: bob)
expect(FeedManager.instance.filter?(:home, s2, alice.id)).to be true
end
it 'returns true for a status whose spoiler text contains a muted keyword' do
Fabricate('Glitch::KeywordMute', account: alice, keyword: 'take')
status = Fabricate(:status, spoiler_text: 'This is a hot take', account: bob)
expect(FeedManager.instance.filter?(:home, status, alice.id)).to be true
end
it 'returns true for a reblog containing a muted keyword' do
Fabricate('Glitch::KeywordMute', account: alice, keyword: 'take')
status = Fabricate(:status, text: 'This is a hot take', account: bob)
reblog = Fabricate(:status, reblog: status, account: jeff)
expect(FeedManager.instance.filter?(:home, reblog, alice.id)).to be true
end
it 'returns true for a reblog whose spoiler text contains a muted keyword' do
Fabricate('Glitch::KeywordMute', account: alice, keyword: 'take')
status = Fabricate(:status, spoiler_text: 'This is a hot take', account: bob)
reblog = Fabricate(:status, reblog: status, account: jeff)
expect(FeedManager.instance.filter?(:home, reblog, alice.id)).to be true
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
it 'returns false if the status is muted by a keyword mute that does not apply to mentions' do
Fabricate('Glitch::KeywordMute', account: alice, keyword: 'take', apply_to_mentions: false)
status = Fabricate(:status, spoiler_text: 'This is a hot take', account: bob)
status.mentions.create!(account_id: alice.id)
expect(FeedManager.instance.filter?(:home, status, alice.id)).to be false
end
context 'for irreversibly muted phrases' do
it 'considers word boundaries when matching' do
alice.custom_filters.create!(phrase: 'bob', context: %w(home), irreversible: true)
@ -247,20 +185,6 @@ 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
it 'returns false for a mention that contains a word muted by a keyword that does not apply to mentions' do
Fabricate('Glitch::KeywordMute', account: bob, keyword: 'take', apply_to_mentions: false)
status = Fabricate(:status, text: 'This is a hot take', account: alice)
bob.follow!(alice)
expect(FeedManager.instance.filter?(:mentions, status, bob.id)).to be false
end
end
end