From bf56e982a9c211396efea16f2ee596102b36db3f Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 12 Jun 2024 15:50:38 +0200 Subject: [PATCH] Fix notifications from limited users being outright dropped (#30559) --- app/lib/feed_manager.rb | 5 +---- spec/lib/feed_manager_spec.rb | 6 +++--- spec/services/notify_service_spec.rb | 29 ++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index 95a687fa41..1fb224a133 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -420,10 +420,7 @@ class FeedManager check_for_blocks = status.active_mentions.pluck(:account_id) check_for_blocks.push(status.in_reply_to_account) if status.reply? && !status.in_reply_to_account_id.nil? - should_filter = blocks_or_mutes?(receiver_id, check_for_blocks, :mentions) # Filter if it's from someone I blocked, in reply to someone I blocked, or mentioning someone I blocked (or muted) - should_filter ||= status.account.silenced? && !Follow.exists?(account_id: receiver_id, target_account_id: status.account_id) # Filter if the account is silenced and I'm not following them - - should_filter + blocks_or_mutes?(receiver_id, check_for_blocks, :mentions) # Filter if it's from someone I blocked, in reply to someone I blocked, or mentioning someone I blocked (or muted) end # Check if status should not be added to the list feed diff --git a/spec/lib/feed_manager_spec.rb b/spec/lib/feed_manager_spec.rb index 613bcb3045..679309bd11 100644 --- a/spec/lib/feed_manager_spec.rb +++ b/spec/lib/feed_manager_spec.rb @@ -206,13 +206,13 @@ RSpec.describe FeedManager do expect(described_class.instance.filter?(:mentions, reply, bob)).to be true end - it 'returns true for status by silenced account who recipient is not following' do + it 'returns false for status by limited account who recipient is not following' do status = Fabricate(:status, text: 'Hello world', account: alice) alice.silence! - expect(described_class.instance.filter?(:mentions, status, bob)).to be true + expect(described_class.instance.filter?(:mentions, status, bob)).to be false end - it 'returns false for status by followed silenced account' do + it 'returns false for status by followed limited account' do status = Fabricate(:status, text: 'Hello world', account: alice) alice.silence! bob.follow!(alice) diff --git a/spec/services/notify_service_spec.rb b/spec/services/notify_service_spec.rb index 6064d2b050..8c810f1c32 100644 --- a/spec/services/notify_service_spec.rb +++ b/spec/services/notify_service_spec.rb @@ -129,6 +129,35 @@ RSpec.describe NotifyService do end end + describe NotifyService::DismissCondition do + subject { described_class.new(notification) } + + let(:activity) { Fabricate(:mention, status: Fabricate(:status)) } + let(:notification) { Fabricate(:notification, type: :mention, activity: activity, from_account: activity.status.account, account: activity.account) } + + describe '#dismiss?' do + context 'when sender is silenced' do + before do + notification.from_account.silence! + end + + it 'returns false' do + expect(subject.dismiss?).to be false + end + end + + context 'when recipient has blocked sender' do + before do + notification.account.block!(notification.from_account) + end + + it 'returns true' do + expect(subject.dismiss?).to be true + end + end + end + end + describe NotifyService::FilterCondition do subject { described_class.new(notification) }