Fix filtering of mentions from filtered-on-their-origin-server accounts (#37583)

This commit is contained in:
Claire
2026-01-27 10:53:21 +01:00
committed by GitHub
parent cd7ffb5a10
commit 73fc40993b
5 changed files with 67 additions and 13 deletions

View File

@@ -45,7 +45,9 @@ RSpec.describe FanOutOnWriteService do
let(:visibility) { 'public' }
it 'adds status to home feed of author and followers and broadcasts', :inline_jobs do
subject.call(status)
expect { subject.call(status) }
.to change(bob.notifications, :count).by(1)
.and change(eve.notifications, :count).by(1)
expect(status.id)
.to be_in(home_feed_of(alice))
@@ -58,6 +60,14 @@ RSpec.describe FanOutOnWriteService do
expect(redis).to have_received(:publish).with('timeline:public:local', anything)
expect(redis).to have_received(:publish).with('timeline:public:media', anything)
end
context 'with silenced_account_ids' do
it 'calls LocalNotificationWorker with the expected arguments' do
expect { subject.call(status, silenced_account_ids: [eve.id]) }
.to enqueue_sidekiq_job(LocalNotificationWorker).with(bob.id, anything, 'Mention', 'mention')
.and enqueue_sidekiq_job(LocalNotificationWorker).with(eve.id, anything, 'Mention', 'mention', { 'silenced' => true })
end
end
end
context 'when status is limited' do

View File

@@ -224,13 +224,25 @@ RSpec.describe NotifyService do
end
end
context 'when sender is considered silenced through `silenced` option and recipient has a policy to ignore silenced accounts' do
subject { described_class.new(notification, silenced: true) }
before do
notification.account.create_notification_policy!(for_limited_accounts: :drop)
end
it 'returns true' do
expect(subject.drop?).to be true
end
end
context 'when sender is new and recipient has a default policy' do
it 'returns false' do
expect(subject.drop?).to be false
end
end
context 'when sender is new and recipient has a policy to ignore silenced accounts' do
context 'when sender is new and recipient has a policy to ignore new accounts' do
before do
notification.account.create_notification_policy!(for_new_accounts: :drop)
end
@@ -240,7 +252,7 @@ RSpec.describe NotifyService do
end
end
context 'when sender is new and followed and recipient has a policy to ignore silenced accounts' do
context 'when sender is new and followed and recipient has a policy to ignore new accounts' do
before do
notification.account.create_notification_policy!(for_new_accounts: :drop)
notification.account.follow!(notification.from_account)
@@ -300,6 +312,34 @@ RSpec.describe NotifyService do
end
end
context 'when sender is considered silenced through the `silenced` option' do
subject { described_class.new(notification, silenced: true) }
it 'returns true' do
expect(subject.filter?).to be true
end
context 'when recipient follows sender' do
before do
notification.account.follow!(notification.from_account)
end
it 'returns false' do
expect(subject.filter?).to be false
end
end
context 'when recipient is allowing limited accounts' do
before do
notification.account.create_notification_policy!(for_limited_accounts: :accept)
end
it 'returns false' do
expect(subject.filter?).to be false
end
end
end
context 'when recipient is filtering not-followed senders' do
before do
Fabricate(:notification_policy, account: notification.account, filter_not_following: true)