summaryrefslogtreecommitdiff
path: root/app/services/notification_service.rb
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-03-21 20:20:53 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-03-22 15:29:57 -0300
commit0a8c9f72127bfff265059c68c2c19bc1ad4bd5a5 (patch)
tree8670cbe178c4abec4c7bdbbba1ec44451ad6bf41 /app/services/notification_service.rb
parent8df6c3b9604ed7b762fd5485275e10f94e698664 (diff)
downloadgitlab-ce-0a8c9f72127bfff265059c68c2c19bc1ad4bd5a5.tar.gz
Restrict notifications for confidential issues
Diffstat (limited to 'app/services/notification_service.rb')
-rw-r--r--app/services/notification_service.rb12
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