2018-08-15 21:45:57 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-03-19 18:00:41 +00:00
|
|
|
module Emails
|
|
|
|
module Issues
|
2017-12-28 17:25:02 +00:00
|
|
|
def new_issue_email(recipient_id, issue_id, reason = nil)
|
2015-12-09 10:59:25 +00:00
|
|
|
setup_issue_mail(issue_id, recipient_id)
|
|
|
|
|
2017-12-28 17:25:02 +00:00
|
|
|
mail_new_thread(@issue, issue_thread_options(@issue.author_id, recipient_id, reason))
|
2013-03-19 18:00:41 +00:00
|
|
|
end
|
|
|
|
|
2018-02-06 18:09:59 +00:00
|
|
|
def issue_due_email(recipient_id, issue_id, reason = nil)
|
|
|
|
setup_issue_mail(issue_id, recipient_id)
|
|
|
|
|
|
|
|
mail_new_thread(@issue, issue_thread_options(@issue.author_id, recipient_id, reason))
|
|
|
|
end
|
|
|
|
|
2017-12-28 17:25:02 +00:00
|
|
|
def new_mention_in_issue_email(recipient_id, issue_id, updated_by_user_id, reason = nil)
|
2016-08-12 21:54:32 +00:00
|
|
|
setup_issue_mail(issue_id, recipient_id)
|
2017-12-28 17:25:02 +00:00
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
|
2016-08-12 21:54:32 +00:00
|
|
|
end
|
|
|
|
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2017-12-28 17:25:02 +00:00
|
|
|
def reassigned_issue_email(recipient_id, issue_id, previous_assignee_ids, updated_by_user_id, reason = nil)
|
2015-12-09 10:59:25 +00:00
|
|
|
setup_issue_mail(issue_id, recipient_id)
|
|
|
|
|
2017-05-04 12:11:15 +00:00
|
|
|
@previous_assignees = []
|
|
|
|
@previous_assignees = User.where(id: previous_assignee_ids) if previous_assignee_ids.any?
|
|
|
|
|
2017-12-28 17:25:02 +00:00
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
|
2013-03-19 18:00:41 +00:00
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2013-03-19 18:00:41 +00:00
|
|
|
|
2019-05-16 11:59:02 +00:00
|
|
|
def closed_issue_email(recipient_id, issue_id, updated_by_user_id, reason: nil, closed_via: nil)
|
|
|
|
setup_issue_mail(issue_id, recipient_id, closed_via: closed_via)
|
2015-12-09 10:59:25 +00:00
|
|
|
|
2016-02-12 14:58:39 +00:00
|
|
|
@updated_by = User.find(updated_by_user_id)
|
2017-12-28 17:25:02 +00:00
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
|
2016-02-12 14:58:39 +00:00
|
|
|
end
|
|
|
|
|
2017-12-28 17:25:02 +00:00
|
|
|
def relabeled_issue_email(recipient_id, issue_id, label_names, updated_by_user_id, reason = nil)
|
2016-03-15 16:24:55 +00:00
|
|
|
setup_issue_mail(issue_id, recipient_id)
|
2016-03-01 16:33:13 +00:00
|
|
|
|
2016-02-12 14:58:39 +00:00
|
|
|
@label_names = label_names
|
2017-06-29 17:06:35 +00:00
|
|
|
@labels_url = project_labels_url(@project)
|
2017-12-28 17:25:02 +00:00
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
|
2013-03-28 10:14:53 +00:00
|
|
|
end
|
|
|
|
|
2018-11-02 16:29:32 +00:00
|
|
|
def removed_milestone_issue_email(recipient_id, issue_id, updated_by_user_id, reason = nil)
|
|
|
|
setup_issue_mail(issue_id, recipient_id)
|
|
|
|
|
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
|
|
|
|
end
|
|
|
|
|
|
|
|
def changed_milestone_issue_email(recipient_id, issue_id, milestone, updated_by_user_id, reason = nil)
|
|
|
|
setup_issue_mail(issue_id, recipient_id)
|
|
|
|
|
|
|
|
@milestone = milestone
|
|
|
|
@milestone_url = milestone_url(@milestone)
|
2018-12-12 09:51:36 +00:00
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason).merge({
|
|
|
|
template_name: 'changed_milestone_email'
|
|
|
|
}))
|
2018-11-02 16:29:32 +00:00
|
|
|
end
|
|
|
|
|
2017-12-28 17:25:02 +00:00
|
|
|
def issue_status_changed_email(recipient_id, issue_id, status, updated_by_user_id, reason = nil)
|
2015-12-09 10:59:25 +00:00
|
|
|
setup_issue_mail(issue_id, recipient_id)
|
|
|
|
|
|
|
|
@issue_status = status
|
2016-02-12 14:58:39 +00:00
|
|
|
@updated_by = User.find(updated_by_user_id)
|
2017-12-28 17:25:02 +00:00
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
|
2015-11-16 22:53:21 +00:00
|
|
|
end
|
|
|
|
|
2017-12-28 17:25:02 +00:00
|
|
|
def issue_moved_email(recipient, issue, new_issue, updated_by_user, reason = nil)
|
2016-03-15 10:35:40 +00:00
|
|
|
setup_issue_mail(issue.id, recipient.id)
|
|
|
|
|
|
|
|
@new_issue = new_issue
|
|
|
|
@new_project = new_issue.project
|
2019-02-13 10:50:24 +00:00
|
|
|
@can_access_project = recipient.can?(:read_project, @new_project)
|
2017-12-28 17:25:02 +00:00
|
|
|
mail_answer_thread(issue, issue_thread_options(updated_by_user.id, recipient.id, reason))
|
2016-03-15 10:35:40 +00:00
|
|
|
end
|
|
|
|
|
2018-12-06 00:51:30 +00:00
|
|
|
def import_issues_csv_email(user_id, project_id, results)
|
|
|
|
@user = User.find(user_id)
|
|
|
|
@project = Project.find(project_id)
|
|
|
|
@results = results
|
|
|
|
|
|
|
|
mail(to: @user.notification_email, subject: subject('Imported issues')) do |format|
|
|
|
|
format.html { render layout: 'mailer' }
|
|
|
|
format.text { render layout: 'mailer' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-17 10:55:43 +00:00
|
|
|
private
|
|
|
|
|
2019-05-16 11:59:02 +00:00
|
|
|
def setup_issue_mail(issue_id, recipient_id, closed_via: nil)
|
2016-03-01 16:33:13 +00:00
|
|
|
@issue = Issue.find(issue_id)
|
|
|
|
@project = @issue.project
|
2017-06-29 17:06:35 +00:00
|
|
|
@target_url = project_issue_url(@project, @issue)
|
2019-05-16 11:59:02 +00:00
|
|
|
@closed_via = closed_via
|
2016-03-01 16:33:13 +00:00
|
|
|
|
2016-03-15 16:24:55 +00:00
|
|
|
@sent_notification = SentNotification.record(@issue, recipient_id, reply_key)
|
2016-03-01 16:33:13 +00:00
|
|
|
end
|
|
|
|
|
2017-12-28 17:25:02 +00:00
|
|
|
def issue_thread_options(sender_id, recipient_id, reason)
|
2015-11-16 22:53:21 +00:00
|
|
|
{
|
|
|
|
from: sender(sender_id),
|
|
|
|
to: recipient(recipient_id),
|
2017-12-28 17:25:02 +00:00
|
|
|
subject: subject("#{@issue.title} (##{@issue.iid})"),
|
|
|
|
'X-GitLab-NotificationReason' => reason
|
2015-11-16 22:53:21 +00:00
|
|
|
}
|
|
|
|
end
|
2013-03-19 18:00:41 +00:00
|
|
|
end
|
|
|
|
end
|