Change notifications from moderators to not be filtered (#33654)

This commit is contained in:
Claire 2025-01-21 12:39:53 +01:00 committed by GitHub
parent 11786f1114
commit 3dcf5e12b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 8 deletions

View File

@ -34,6 +34,7 @@ class NotifyService < BaseService
@sender = notification.from_account @sender = notification.from_account
@notification = notification @notification = notification
@policy = NotificationPolicy.find_or_initialize_by(account: @recipient) @policy = NotificationPolicy.find_or_initialize_by(account: @recipient)
@from_staff = @sender.local? && @sender.user.present? && @sender.user_role&.bypass_block?(@recipient.user_role)
end end
private private
@ -63,6 +64,14 @@ class NotifyService < BaseService
@sender.silenced? && not_following? @sender.silenced? && not_following?
end end
def message?
@notification.type == :mention
end
def from_staff?
@from_staff
end
def private_mention_not_in_response? def private_mention_not_in_response?
@notification.type == :mention && @notification.target_status.direct_visibility? && !response_to_recipient? @notification.type == :mention && @notification.target_status.direct_visibility? && !response_to_recipient?
end end
@ -129,14 +138,6 @@ class NotifyService < BaseService
FeedManager.instance.filter?(:mentions, @notification.target_status, @recipient) FeedManager.instance.filter?(:mentions, @notification.target_status, @recipient)
end end
def message?
@notification.type == :mention
end
def from_staff?
@sender.local? && @sender.user.present? && @sender.user_role&.bypass_block?(@recipient.user_role)
end
def from_self? def from_self?
@recipient.id == @sender.id @recipient.id == @sender.id
end end
@ -174,6 +175,7 @@ class NotifyService < BaseService
def filter? def filter?
return false unless filterable_type? return false unless filterable_type?
return false if override_for_sender? return false if override_for_sender?
return false if message? && from_staff?
filtered_by_limited_accounts_policy? || filtered_by_limited_accounts_policy? ||
filtered_by_not_following_policy? || filtered_by_not_following_policy? ||

View File

@ -319,6 +319,16 @@ RSpec.describe NotifyService do
end end
end end
context 'when sender is a moderator' do
let(:sender_role) { Fabricate(:user_role, highlighted: true, permissions: UserRole::FLAGS[:manage_users]) }
let(:sender) { Fabricate(:user, role: sender_role).account }
let(:activity) { Fabricate(:mention, status: Fabricate(:status, account: sender)) }
it 'returns false' do
expect(subject.filter?).to be false
end
end
context 'when sender is followed by recipient' do context 'when sender is followed by recipient' do
before do before do
notification.account.follow!(notification.from_account) notification.account.follow!(notification.from_account)