summaryrefslogtreecommitdiff
path: root/app/services/notification_service.rb
diff options
context:
space:
mode:
authorDimitris Karakasilis <jimmykarily@gmail.com>2016-09-26 18:34:56 +0300
committerDimitris Karakasilis <jimmykarily@gmail.com>2016-09-29 14:58:36 +0300
commit6e6f34bffb641ae698177055b8f3528ec41fb7c8 (patch)
treeb4311ff4dc0d84c7baa4bb0cf9096b7228232937 /app/services/notification_service.rb
parentf78c86bbd5c0220e9b408501550a0bfe8f1b5245 (diff)
downloadgitlab-ce-6e6f34bffb641ae698177055b8f3528ec41fb7c8.tar.gz
Notify current_user about automatic merge after successful build
Fixes: https://gitlab.com/gitlab-org/gitlab-ce/issues/14409
Diffstat (limited to 'app/services/notification_service.rb')
-rw-r--r--app/services/notification_service.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb
index 6139ed56e25..2cc0c31d77d 100644
--- a/app/services/notification_service.rb
+++ b/app/services/notification_service.rb
@@ -134,7 +134,8 @@ class NotificationService
merge_request,
merge_request.target_project,
current_user,
- :merged_merge_request_email
+ :merged_merge_request_email,
+ skip_current_user: !merge_request.merge_when_build_succeeds?
)
end
@@ -514,9 +515,11 @@ class NotificationService
end
end
- def close_resource_email(target, project, current_user, method)
+ def close_resource_email(target, project, current_user, method, skip_current_user: true)
action = method == :merged_merge_request_email ? "merge" : "close"
- recipients = build_recipients(target, project, current_user, action: action)
+
+ recipients = build_recipients(target, project, current_user, action: action,
+ skip_current_user: skip_current_user)
recipients.each do |recipient|
mailer.send(method, recipient.id, target.id, current_user.id).deliver_later
@@ -557,7 +560,7 @@ class NotificationService
end
end
- def build_recipients(target, project, current_user, action: nil, previous_assignee: nil)
+ def build_recipients(target, project, current_user, action: nil, previous_assignee: nil, skip_current_user: true)
custom_action = build_custom_key(action, target)
recipients = target.participants(current_user)
@@ -586,7 +589,8 @@ class NotificationService
recipients = reject_unsubscribed_users(recipients, target)
recipients = reject_users_without_access(recipients, target)
- recipients.delete(current_user)
+ recipients.delete(current_user) if skip_current_user
+
recipients.uniq
end