From 310231dbed83e66ad4d17b8c25f225f60b30eeb7 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Thu, 3 Jul 2014 13:40:21 +0200 Subject: [PATCH] Reopen mr email notification. --- app/mailers/emails/merge_requests.rb | 13 +++++++++++++ app/services/merge_requests/reopen_service.rb | 1 + app/services/notification_service.rb | 4 ++++ .../notify/merge_request_status_email.html.haml | 2 ++ .../notify/merge_request_status_email.text.haml | 8 ++++++++ 5 files changed, 28 insertions(+) create mode 100644 app/views/notify/merge_request_status_email.html.haml create mode 100644 app/views/notify/merge_request_status_email.text.haml diff --git a/app/mailers/emails/merge_requests.rb b/app/mailers/emails/merge_requests.rb index ea5671c4502..354c58678d5 100644 --- a/app/mailers/emails/merge_requests.rb +++ b/app/mailers/emails/merge_requests.rb @@ -41,6 +41,19 @@ module Emails to: recipient(recipient_id), subject: subject("#{@merge_request.title} (##{@merge_request.iid})")) end + + def merge_request_status_email(recipient_id, merge_request_id, status, updated_by_user_id) + @merge_request = MergeRequest.find(merge_request_id) + @mr_status = status + @project = @merge_request.project + @updated_by = User.find updated_by_user_id + @target_url = project_merge_request_url(@project, @merge_request) + set_reference("merge_request_#{merge_request_id}") + + mail(from: sender(updated_by_user_id), + to: recipient(recipient_id), + subject: subject("#{@merge_request.title} (##{@merge_request.iid}) #{@mr_status}")) + end end # Over rides default behavour to show source/target diff --git a/app/services/merge_requests/reopen_service.rb b/app/services/merge_requests/reopen_service.rb index 2eb13d3e0e1..bd68919a550 100644 --- a/app/services/merge_requests/reopen_service.rb +++ b/app/services/merge_requests/reopen_service.rb @@ -3,6 +3,7 @@ module MergeRequests def execute(merge_request) if merge_request.reopen event_service.reopen_mr(merge_request, current_user) + notification_service.reopen_mr(merge_request, current_user) create_note(merge_request) execute_hooks(merge_request) merge_request.reload_code diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index f39b743b033..9f86cfbbeaf 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -99,6 +99,10 @@ class NotificationService end end + def reopen_mr(merge_request, current_user) + reopen_resource_email(merge_request, merge_request.target_project, current_user, 'merge_request_status_email', 'reopened') + end + # Notify new user with email after creation def new_user(user) # Don't email omniauth created users diff --git a/app/views/notify/merge_request_status_email.html.haml b/app/views/notify/merge_request_status_email.html.haml new file mode 100644 index 00000000000..c9bf04f514e --- /dev/null +++ b/app/views/notify/merge_request_status_email.html.haml @@ -0,0 +1,2 @@ +%p + = "Merge Request ##{@merge_request.iid} was #{@mr_status} by #{@updated_by.name}" diff --git a/app/views/notify/merge_request_status_email.text.haml b/app/views/notify/merge_request_status_email.text.haml new file mode 100644 index 00000000000..8750bf86e2c --- /dev/null +++ b/app/views/notify/merge_request_status_email.text.haml @@ -0,0 +1,8 @@ += "Merge Request ##{@merge_request.iid} was #{@mr_status} by #{@updated_by.name}" + +Merge Request url: #{project_merge_request_url(@merge_request.target_project, @merge_request)} + += merge_path_description(@merge_request, 'to') + +Author: #{@merge_request.author_name} +Assignee: #{@merge_request.assignee_name}