diff options
| author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-03-21 20:20:53 -0300 |
|---|---|---|
| committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-03-22 15:29:57 -0300 |
| commit | 0a8c9f72127bfff265059c68c2c19bc1ad4bd5a5 (patch) | |
| tree | 8670cbe178c4abec4c7bdbbba1ec44451ad6bf41 /app/services/notification_service.rb | |
| parent | 8df6c3b9604ed7b762fd5485275e10f94e698664 (diff) | |
| download | gitlab-ce-0a8c9f72127bfff265059c68c2c19bc1ad4bd5a5.tar.gz | |
Restrict notifications for confidential issues
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 |
