diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-10-21 18:16:39 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-10-21 18:18:03 +0800 |
commit | 6061c9fa3d942c4b1aa466ee8f5f8eb3ae48853e (patch) | |
tree | 58420c8b0a2f5a6649c6aba516223942d4fc60c9 /app | |
parent | 1cdad622aacf9ae7e7d61e575aaa77dddf7ae7b9 (diff) | |
download | gitlab-ce-6061c9fa3d942c4b1aa466ee8f5f8eb3ae48853e.tar.gz |
Send only to users have :read_build access, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6342#note_17193335
Diffstat (limited to 'app')
-rw-r--r-- | app/policies/ci/build_policy.rb | 2 | ||||
-rw-r--r-- | app/policies/ci/pipeline_policy.rb | 4 | ||||
-rw-r--r-- | app/services/notification_service.rb | 11 |
3 files changed, 13 insertions, 4 deletions
diff --git a/app/policies/ci/build_policy.rb b/app/policies/ci/build_policy.rb index 2232e231cf8..8b25332b73c 100644 --- a/app/policies/ci/build_policy.rb +++ b/app/policies/ci/build_policy.rb @@ -5,7 +5,7 @@ module Ci # If we can't read build we should also not have that # ability when looking at this in context of commit_status - %w(read create update admin).each do |rule| + %w[read create update admin].each do |rule| cannot! :"#{rule}_commit_status" unless can? :"#{rule}_build" end end diff --git a/app/policies/ci/pipeline_policy.rb b/app/policies/ci/pipeline_policy.rb new file mode 100644 index 00000000000..3d2eef1c50c --- /dev/null +++ b/app/policies/ci/pipeline_policy.rb @@ -0,0 +1,4 @@ +module Ci + class PipelinePolicy < BuildPolicy + end +end diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 2cc9a9fd7bf..f48255b2e6c 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -489,9 +489,14 @@ class NotificationService end def reject_users_without_access(recipients, target) - return recipients unless target.is_a?(Issuable) - - ability = :"read_#{target.to_ability_name}" + ability = case target + when Issuable + :"read_#{target.to_ability_name}" + when Ci::Pipeline + :read_build # We have build trace in pipeline emails + end + + return recipients unless ability recipients.select do |user| user.can?(ability, target) |