2013-03-19 14:00:41 -04:00
|
|
|
module Emails
|
|
|
|
module MergeRequests
|
2013-03-28 06:52:44 -04:00
|
|
|
def new_merge_request_email(recipient_id, merge_request_id)
|
2015-12-09 05:59:25 -05:00
|
|
|
setup_merge_request_mail(merge_request_id, recipient_id)
|
|
|
|
|
2016-03-01 11:33:13 -05:00
|
|
|
mail_new_thread(@merge_request, merge_request_thread_options(@merge_request.author_id, recipient_id))
|
2013-03-19 14:00:41 -04:00
|
|
|
end
|
|
|
|
|
2016-08-15 09:47:16 -04:00
|
|
|
def new_mention_in_merge_request_email(recipient_id, merge_request_id, updated_by_user_id)
|
|
|
|
setup_merge_request_mail(merge_request_id, recipient_id)
|
|
|
|
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id))
|
|
|
|
end
|
|
|
|
|
2014-02-17 12:49:42 -05:00
|
|
|
def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id, updated_by_user_id)
|
2015-12-09 05:59:25 -05:00
|
|
|
setup_merge_request_mail(merge_request_id, recipient_id)
|
|
|
|
|
2014-01-19 13:55:59 -05:00
|
|
|
@previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id
|
2016-03-01 11:33:13 -05:00
|
|
|
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id))
|
2013-03-19 14:00:41 -04:00
|
|
|
end
|
2013-03-28 06:14:53 -04:00
|
|
|
|
2016-03-01 11:33:13 -05:00
|
|
|
def relabeled_merge_request_email(recipient_id, merge_request_id, label_names, updated_by_user_id)
|
2016-03-15 12:24:55 -04:00
|
|
|
setup_merge_request_mail(merge_request_id, recipient_id)
|
2016-03-01 11:33:13 -05:00
|
|
|
|
2016-02-12 09:58:39 -05:00
|
|
|
@label_names = label_names
|
2017-06-29 13:06:35 -04:00
|
|
|
@labels_url = project_labels_url(@project)
|
2016-03-01 11:33:13 -05:00
|
|
|
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id))
|
2016-02-12 09:58:39 -05:00
|
|
|
end
|
|
|
|
|
2013-03-28 06:14:53 -04:00
|
|
|
def closed_merge_request_email(recipient_id, merge_request_id, updated_by_user_id)
|
2015-12-09 05:59:25 -05:00
|
|
|
setup_merge_request_mail(merge_request_id, recipient_id)
|
|
|
|
|
2016-02-12 09:58:39 -05:00
|
|
|
@updated_by = User.find(updated_by_user_id)
|
2016-03-01 11:33:13 -05:00
|
|
|
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id))
|
2013-03-28 06:14:53 -04:00
|
|
|
end
|
|
|
|
|
2014-03-24 10:11:35 -04:00
|
|
|
def merged_merge_request_email(recipient_id, merge_request_id, updated_by_user_id)
|
2015-12-09 05:59:25 -05:00
|
|
|
setup_merge_request_mail(merge_request_id, recipient_id)
|
|
|
|
|
2016-03-01 11:33:13 -05:00
|
|
|
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id))
|
2013-03-28 06:14:53 -04:00
|
|
|
end
|
2014-07-03 07:40:21 -04:00
|
|
|
|
|
|
|
def merge_request_status_email(recipient_id, merge_request_id, status, updated_by_user_id)
|
2015-12-09 05:59:25 -05:00
|
|
|
setup_merge_request_mail(merge_request_id, recipient_id)
|
|
|
|
|
2014-07-03 07:40:21 -04:00
|
|
|
@mr_status = status
|
2016-02-12 09:58:39 -05:00
|
|
|
@updated_by = User.find(updated_by_user_id)
|
2016-03-01 11:33:13 -05:00
|
|
|
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id))
|
2015-12-09 05:59:25 -05:00
|
|
|
end
|
|
|
|
|
2016-07-28 23:00:32 -04:00
|
|
|
def resolved_all_discussions_email(recipient_id, merge_request_id, resolved_by_user_id)
|
|
|
|
setup_merge_request_mail(merge_request_id, recipient_id)
|
|
|
|
|
|
|
|
@resolved_by = User.find(resolved_by_user_id)
|
|
|
|
mail_answer_thread(@merge_request, merge_request_thread_options(resolved_by_user_id, recipient_id))
|
|
|
|
end
|
|
|
|
|
2015-12-09 05:59:25 -05:00
|
|
|
private
|
|
|
|
|
2016-03-15 12:24:55 -04:00
|
|
|
def setup_merge_request_mail(merge_request_id, recipient_id)
|
2015-12-09 05:59:25 -05:00
|
|
|
@merge_request = MergeRequest.find(merge_request_id)
|
|
|
|
@project = @merge_request.project
|
2017-06-29 13:06:35 -04:00
|
|
|
@target_url = project_merge_request_url(@project, @merge_request)
|
2016-03-01 11:33:13 -05:00
|
|
|
|
2016-03-15 12:24:55 -04:00
|
|
|
@sent_notification = SentNotification.record(@merge_request, recipient_id, reply_key)
|
2016-03-01 11:33:13 -05:00
|
|
|
end
|
2015-08-18 18:46:36 -04:00
|
|
|
|
2016-03-01 11:33:13 -05:00
|
|
|
def merge_request_thread_options(sender_id, recipient_id)
|
|
|
|
{
|
|
|
|
from: sender(sender_id),
|
|
|
|
to: recipient(recipient_id),
|
2016-04-19 02:32:02 -04:00
|
|
|
subject: subject("#{@merge_request.title} (#{@merge_request.to_reference})")
|
2016-03-01 11:33:13 -05:00
|
|
|
}
|
2014-07-03 07:40:21 -04:00
|
|
|
end
|
2013-03-19 14:00:41 -04:00
|
|
|
end
|
|
|
|
end
|