diff options
Diffstat (limited to 'app/services/notification_service.rb')
-rw-r--r-- | app/services/notification_service.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 3bdf00a8291..eff0d96f93d 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -162,6 +162,7 @@ class NotificationService recipients = add_subscribed_users(recipients, note.noteable) recipients = reject_unsubscribed_users(recipients, note.noteable) + recipients = reject_users_without_access(recipients, note.noteable) recipients.delete(note.author) recipients = recipients.uniq @@ -376,6 +377,14 @@ class NotificationService end end + def reject_users_without_access(recipients, target) + return recipients unless target.is_a?(Issue) + + recipients.select do |user| + user.can?(:read_issue, target) + end + end + def add_subscribed_users(recipients, target) return recipients unless target.respond_to? :subscribers @@ -464,15 +473,16 @@ class NotificationService end recipients = reject_unsubscribed_users(recipients, target) + recipients = reject_users_without_access(recipients, target) recipients.delete(current_user) - recipients.uniq end def build_relabeled_recipients(target, current_user, labels:) recipients = add_labels_subscribers([], target, labels: labels) recipients = reject_unsubscribed_users(recipients, target) + recipients = reject_users_without_access(recipients, target) recipients.delete(current_user) recipients.uniq end |