debian-mirror-gitlab/app/mailers/emails/merge_requests.rb

77 lines
3.3 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
module Emails
module MergeRequests
2018-03-17 18:26:18 +05:30
def new_merge_request_email(recipient_id, merge_request_id, reason = nil)
setup_merge_request_mail(merge_request_id, recipient_id)
2018-03-17 18:26:18 +05:30
mail_new_thread(@merge_request, merge_request_thread_options(@merge_request.author_id, recipient_id, reason))
2014-09-02 18:07:02 +05:30
end
2018-03-17 18:26:18 +05:30
def new_mention_in_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil)
2016-09-13 17:45:13 +05:30
setup_merge_request_mail(merge_request_id, recipient_id)
2018-03-17 18:26:18 +05:30
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason))
2016-09-13 17:45:13 +05:30
end
2018-03-17 18:26:18 +05:30
def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id, updated_by_user_id, reason = nil)
setup_merge_request_mail(merge_request_id, recipient_id)
2014-09-02 18:07:02 +05:30
@previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id
2018-03-17 18:26:18 +05:30
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason))
2016-06-02 11:05:42 +05:30
end
2018-03-17 18:26:18 +05:30
def relabeled_merge_request_email(recipient_id, merge_request_id, label_names, updated_by_user_id, reason = nil)
2016-06-02 11:05:42 +05:30
setup_merge_request_mail(merge_request_id, recipient_id)
@label_names = label_names
2017-09-10 17:25:29 +05:30
@labels_url = project_labels_url(@project)
2018-03-17 18:26:18 +05:30
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason))
2014-09-02 18:07:02 +05:30
end
2018-03-17 18:26:18 +05:30
def closed_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil)
setup_merge_request_mail(merge_request_id, recipient_id)
2016-06-02 11:05:42 +05:30
@updated_by = User.find(updated_by_user_id)
2018-03-17 18:26:18 +05:30
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason))
2014-09-02 18:07:02 +05:30
end
2018-03-17 18:26:18 +05:30
def merged_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil)
setup_merge_request_mail(merge_request_id, recipient_id)
2018-03-17 18:26:18 +05:30
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason))
2014-09-02 18:07:02 +05:30
end
2018-03-17 18:26:18 +05:30
def merge_request_status_email(recipient_id, merge_request_id, status, updated_by_user_id, reason = nil)
setup_merge_request_mail(merge_request_id, recipient_id)
2014-09-02 18:07:02 +05:30
@mr_status = status
2016-06-02 11:05:42 +05:30
@updated_by = User.find(updated_by_user_id)
2018-03-17 18:26:18 +05:30
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason))
end
2018-03-17 18:26:18 +05:30
def resolved_all_discussions_email(recipient_id, merge_request_id, resolved_by_user_id, reason = nil)
2016-09-13 17:45:13 +05:30
setup_merge_request_mail(merge_request_id, recipient_id)
@resolved_by = User.find(resolved_by_user_id)
2018-03-17 18:26:18 +05:30
mail_answer_thread(@merge_request, merge_request_thread_options(resolved_by_user_id, recipient_id, reason))
2016-09-13 17:45:13 +05:30
end
private
def setup_merge_request_mail(merge_request_id, recipient_id)
@merge_request = MergeRequest.find(merge_request_id)
@project = @merge_request.project
2017-09-10 17:25:29 +05:30
@target_url = project_merge_request_url(@project, @merge_request)
2014-09-02 18:07:02 +05:30
@sent_notification = SentNotification.record(@merge_request, recipient_id, reply_key)
2014-09-02 18:07:02 +05:30
end
2016-06-02 11:05:42 +05:30
2018-03-17 18:26:18 +05:30
def merge_request_thread_options(sender_id, recipient_id, reason = nil)
2016-06-02 11:05:42 +05:30
{
from: sender(sender_id),
to: recipient(recipient_id),
2018-03-17 18:26:18 +05:30
subject: subject("#{@merge_request.title} (#{@merge_request.to_reference})"),
'X-GitLab-NotificationReason' => reason
2016-06-02 11:05:42 +05:30
}
end
2014-09-02 18:07:02 +05:30
end
end