1
0
mirror of https://github.com/mastodon/mastodon synced 2024-11-30 15:58:14 +09:00

Add UserRole#bypass_block? method for notification check (#32974)

This commit is contained in:
Matt Jankowski 2024-11-26 04:45:47 -05:00 committed by GitHub
parent f0855fd41f
commit a27bafa596
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -142,6 +142,10 @@ class UserRole < ApplicationRecord
other_role.nil? || position > other_role.position other_role.nil? || position > other_role.position
end end
def bypass_block?(role)
overrides?(role) && highlighted? && can?(*Flags::CATEGORIES[:moderation])
end
def computed_permissions def computed_permissions
# If called on the everyone role, no further computation needed # If called on the everyone role, no further computation needed
return permissions if everyone? return permissions if everyone?

View File

@ -134,7 +134,7 @@ class NotifyService < BaseService
end end
def from_staff? def from_staff?
@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&.bypass_block?(@recipient.user_role)
end end
def from_self? def from_self?