Skip to content

Commit

Permalink
Fix broken notifications for mentions from local moderators in 4.2.11 (
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored Aug 19, 2024
1 parent a02ff33 commit d675803
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/notify_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def response_to_recipient?

def from_staff?
sender = @notification.from_account
sender.local? && sender.user.present? && sender.user_role&.overrides?(@recipient.user_role) && @sender.user_role&.highlighted? && sender.user_role&.can?(*UserRole::Flags::CATEGORIES[:moderation])
sender.local? && sender.user.present? && sender.user_role&.overrides?(@recipient.user_role) && sender.user_role&.highlighted? && sender.user_role&.can?(*UserRole::Flags::CATEGORIES[:moderation].map(&:to_sym))
end

def optional_non_following_and_direct?
Expand Down
11 changes: 11 additions & 0 deletions spec/services/notify_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
expect { subject }.to_not change(Notification, :count)
end

context 'when the sender is a local moderator' do
let(:sender) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:type) { :mention }
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender)) }

it 'does notify when the sender is blocked' do
recipient.block!(sender)
expect { subject }.to change(Notification, :count).by(1)
end
end

it 'does not notify when sender is muted with hide_notifications' do
recipient.mute!(sender, notifications: true)
expect { subject }.to_not change(Notification, :count)
Expand Down

0 comments on commit d675803

Please sign in to comment.