diff options
author | YarNayar <YarTheGreat@gmail.com> | 2017-07-25 14:56:09 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-03-26 13:24:52 +0100 |
commit | 99b01e23598e6b0b2bcae891939ea28c67f7b2e9 (patch) | |
tree | c32d351419cd399dcb104eac54563b7028bbd1d8 /app/services | |
parent | bb9d360c0a7daed6aa08a0635e084c314c2c8b3e (diff) | |
download | gitlab-ce-99b01e23598e6b0b2bcae891939ea28c67f7b2e9.tar.gz |
Send notification emails when push to a merge requestYarNayar/gitlab-ce-23460-send-email-when-pushing-more-commits-to-the-merge-request
Closes #23460
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/merge_requests/refresh_service.rb | 8 | ||||
-rw-r--r-- | app/services/notification_service.rb | 10 |
2 files changed, 15 insertions, 3 deletions
diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb index 18c40ce8992..1fb1796b56c 100644 --- a/app/services/merge_requests/refresh_service.rb +++ b/app/services/merge_requests/refresh_service.rb @@ -21,7 +21,7 @@ module MergeRequests comment_mr_branch_presence_changed end - comment_mr_with_commits + notify_about_push mark_mr_as_wip_from_commits execute_mr_web_hooks @@ -141,8 +141,8 @@ module MergeRequests end end - # Add comment about pushing new commits to merge requests - def comment_mr_with_commits + # Add comment about pushing new commits to merge requests and send nofitication emails + def notify_about_push return unless @commits.present? merge_requests_for_source_branch.each do |merge_request| @@ -155,6 +155,8 @@ module MergeRequests SystemNoteService.add_commits(merge_request, merge_request.project, @current_user, new_commits, existing_commits, @oldrev) + + notification_service.push_to_merge_request(merge_request, @current_user, new_commits: new_commits, existing_commits: existing_commits) end end diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index d7d2cde1004..f94c76cf3ac 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -113,6 +113,16 @@ class NotificationService new_resource_email(merge_request, :new_merge_request_email) end + def push_to_merge_request(merge_request, current_user, new_commits: [], existing_commits: []) + new_commits = new_commits.map { |c| { short_id: c.short_id, title: c.title } } + existing_commits = existing_commits.map { |c| { short_id: c.short_id, title: c.title } } + recipients = NotificationRecipientService.build_recipients(merge_request, current_user, action: "push_to") + + recipients.each do |recipient| + mailer.send(:push_to_merge_request_email, recipient.user.id, merge_request.id, current_user.id, recipient.reason, new_commits: new_commits, existing_commits: existing_commits).deliver_later + end + end + # When merge request text is updated, we should send an email to: # # * newly mentioned project team members with notification level higher than Participating |