Skip to content

Commit

Permalink
Add UserRole#bypass_block? method for notification check (mastodon#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski authored Nov 26, 2024
1 parent f0855fd commit a27bafa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/models/user_role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ def overrides?(other_role)
other_role.nil? || position > other_role.position
end

def bypass_block?(role)
overrides?(role) && highlighted? && can?(*Flags::CATEGORIES[:moderation])
end

def computed_permissions
# If called on the everyone role, no further computation needed
return permissions if everyone?
Expand Down
2 changes: 1 addition & 1 deletion app/services/notify_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def message?
end

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

def from_self?
Expand Down

0 comments on commit a27bafa

Please sign in to comment.