2013-03-19 18:00:41 +00:00
|
|
|
module Emails
|
|
|
|
module MergeRequests
|
2013-03-28 10:52:44 +00:00
|
|
|
def new_merge_request_email(recipient_id, merge_request_id)
|
2013-03-19 18:00:41 +00:00
|
|
|
@merge_request = MergeRequest.find(merge_request_id)
|
2013-12-16 17:56:47 +00:00
|
|
|
@project = @merge_request.project
|
2014-02-18 10:12:01 +00:00
|
|
|
@target_url = project_merge_request_url(@project, @merge_request)
|
2014-06-18 11:41:12 +00:00
|
|
|
set_message_id("merge_request_#{merge_request_id}")
|
|
|
|
mail(from: sender(@merge_request.author_id),
|
|
|
|
to: recipient(recipient_id),
|
|
|
|
subject: subject("#{@merge_request.title} (##{@merge_request.iid})"))
|
2013-03-19 18:00:41 +00:00
|
|
|
end
|
|
|
|
|
2014-02-17 17:49:42 +00:00
|
|
|
def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id, updated_by_user_id)
|
2013-03-19 18:00:41 +00:00
|
|
|
@merge_request = MergeRequest.find(merge_request_id)
|
2014-01-19 18:55:59 +00:00
|
|
|
@previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id
|
2013-12-16 17:56:47 +00:00
|
|
|
@project = @merge_request.project
|
2014-02-18 10:12:01 +00:00
|
|
|
@target_url = project_merge_request_url(@project, @merge_request)
|
2014-06-18 11:41:12 +00:00
|
|
|
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})"))
|
2013-03-19 18:00:41 +00:00
|
|
|
end
|
2013-03-28 10:14:53 +00:00
|
|
|
|
|
|
|
def closed_merge_request_email(recipient_id, merge_request_id, updated_by_user_id)
|
|
|
|
@merge_request = MergeRequest.find(merge_request_id)
|
|
|
|
@updated_by = User.find updated_by_user_id
|
2013-12-16 17:56:47 +00:00
|
|
|
@project = @merge_request.project
|
2014-02-18 10:12:01 +00:00
|
|
|
@target_url = project_merge_request_url(@project, @merge_request)
|
2014-06-18 11:41:12 +00:00
|
|
|
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})"))
|
2013-03-28 10:14:53 +00:00
|
|
|
end
|
|
|
|
|
2014-03-24 14:11:35 +00:00
|
|
|
def merged_merge_request_email(recipient_id, merge_request_id, updated_by_user_id)
|
2013-03-28 10:14:53 +00:00
|
|
|
@merge_request = MergeRequest.find(merge_request_id)
|
2013-12-16 17:56:47 +00:00
|
|
|
@project = @merge_request.project
|
2014-02-18 10:12:01 +00:00
|
|
|
@target_url = project_merge_request_url(@project, @merge_request)
|
2014-06-18 11:41:12 +00:00
|
|
|
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})"))
|
2013-03-28 10:14:53 +00:00
|
|
|
end
|
2013-03-19 18:00:41 +00:00
|
|
|
end
|
2013-04-25 14:15:33 +00:00
|
|
|
|
|
|
|
# Over rides default behavour to show source/target
|
|
|
|
# Formats arguments into a String suitable for use as an email subject
|
|
|
|
#
|
|
|
|
# extra - Extra Strings to be inserted into the subject
|
|
|
|
#
|
|
|
|
# Examples
|
|
|
|
#
|
|
|
|
# >> subject('Lorem ipsum')
|
|
|
|
# => "GitLab Merge Request | Lorem ipsum"
|
|
|
|
#
|
|
|
|
# # Automatically inserts Project name:
|
|
|
|
# Forked MR
|
|
|
|
# => source project => <Project id: 1, name: "Ruby on Rails", path: "ruby_on_rails", ...>
|
|
|
|
# => target project => <Project id: 2, name: "My Ror", path: "ruby_on_rails", ...>
|
|
|
|
# => source branch => source
|
|
|
|
# => target branch => target
|
|
|
|
# >> subject('Lorem ipsum')
|
|
|
|
# => "GitLab Merge Request | Ruby on Rails:source >> My Ror:target | Lorem ipsum "
|
|
|
|
#
|
|
|
|
# Non Forked MR
|
|
|
|
# => source project => <Project id: 1, name: "Ruby on Rails", path: "ruby_on_rails", ...>
|
|
|
|
# => target project => <Project id: 1, name: "Ruby on Rails", path: "ruby_on_rails", ...>
|
|
|
|
# => source branch => source
|
|
|
|
# => target branch => target
|
|
|
|
# >> subject('Lorem ipsum')
|
|
|
|
# => "GitLab Merge Request | Ruby on Rails | source >> target | Lorem ipsum "
|
|
|
|
# # Accepts multiple arguments
|
|
|
|
# >> subject('Lorem ipsum', 'Dolor sit amet')
|
|
|
|
# => "GitLab Merge Request | Lorem ipsum | Dolor sit amet"
|
|
|
|
def subject(*extra)
|
2014-02-17 15:45:28 +00:00
|
|
|
subject = "Merge Request | "
|
2013-04-25 14:15:33 +00:00
|
|
|
if @merge_request.for_fork?
|
|
|
|
subject << "#{@merge_request.source_project.name_with_namespace}:#{merge_request.source_branch} >> #{@merge_request.target_project.name_with_namespace}:#{merge_request.target_branch}"
|
|
|
|
else
|
|
|
|
subject << "#{@merge_request.source_project.name_with_namespace} | #{merge_request.source_branch} >> #{merge_request.target_branch}"
|
|
|
|
end
|
|
|
|
subject << " | " + extra.join(' | ') if extra.present?
|
|
|
|
subject
|
|
|
|
end
|
2013-07-17 14:35:11 +00:00
|
|
|
|
2013-03-19 18:00:41 +00:00
|
|
|
end
|