2013-03-19 14:00:41 -04:00
|
|
|
module Emails
|
|
|
|
module Issues
|
2017-12-28 12:25:02 -05:00
|
|
|
def new_issue_email(recipient_id, issue_id, reason = nil)
|
2015-12-09 05:59:25 -05:00
|
|
|
setup_issue_mail(issue_id, recipient_id)
|
|
|
|
|
2017-12-28 12:25:02 -05:00
|
|
|
mail_new_thread(@issue, issue_thread_options(@issue.author_id, recipient_id, reason))
|
2013-03-19 14:00:41 -04:00
|
|
|
end
|
|
|
|
|
2017-12-28 12:25:02 -05:00
|
|
|
def new_mention_in_issue_email(recipient_id, issue_id, updated_by_user_id, reason = nil)
|
2016-08-12 17:54:32 -04:00
|
|
|
setup_issue_mail(issue_id, recipient_id)
|
2017-12-28 12:25:02 -05:00
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
|
2016-08-12 17:54:32 -04:00
|
|
|
end
|
|
|
|
|
2017-12-28 12:25:02 -05:00
|
|
|
def reassigned_issue_email(recipient_id, issue_id, previous_assignee_ids, updated_by_user_id, reason = nil)
|
2015-12-09 05:59:25 -05:00
|
|
|
setup_issue_mail(issue_id, recipient_id)
|
|
|
|
|
2017-05-04 08:11:15 -04:00
|
|
|
@previous_assignees = []
|
|
|
|
@previous_assignees = User.where(id: previous_assignee_ids) if previous_assignee_ids.any?
|
|
|
|
|
2017-12-28 12:25:02 -05:00
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
|
2013-03-19 14:00:41 -04:00
|
|
|
end
|
|
|
|
|
2017-12-28 12:25:02 -05:00
|
|
|
def closed_issue_email(recipient_id, issue_id, updated_by_user_id, reason = nil)
|
2015-12-09 05:59:25 -05:00
|
|
|
setup_issue_mail(issue_id, recipient_id)
|
|
|
|
|
2016-02-12 09:58:39 -05:00
|
|
|
@updated_by = User.find(updated_by_user_id)
|
2017-12-28 12:25:02 -05:00
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
|
2016-02-12 09:58:39 -05:00
|
|
|
end
|
|
|
|
|
2017-12-28 12:25:02 -05:00
|
|
|
def relabeled_issue_email(recipient_id, issue_id, label_names, updated_by_user_id, reason = nil)
|
2016-03-15 12:24:55 -04:00
|
|
|
setup_issue_mail(issue_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)
|
2017-12-28 12:25:02 -05:00
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
|
2013-03-28 06:14:53 -04:00
|
|
|
end
|
|
|
|
|
2017-12-28 12:25:02 -05:00
|
|
|
def issue_status_changed_email(recipient_id, issue_id, status, updated_by_user_id, reason = nil)
|
2015-12-09 05:59:25 -05:00
|
|
|
setup_issue_mail(issue_id, recipient_id)
|
|
|
|
|
|
|
|
@issue_status = status
|
2016-02-12 09:58:39 -05:00
|
|
|
@updated_by = User.find(updated_by_user_id)
|
2017-12-28 12:25:02 -05:00
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
|
2015-11-16 17:53:21 -05:00
|
|
|
end
|
|
|
|
|
2017-12-28 12:25:02 -05:00
|
|
|
def issue_moved_email(recipient, issue, new_issue, updated_by_user, reason = nil)
|
2016-03-15 06:35:40 -04:00
|
|
|
setup_issue_mail(issue.id, recipient.id)
|
|
|
|
|
|
|
|
@new_issue = new_issue
|
|
|
|
@new_project = new_issue.project
|
2017-12-28 12:25:02 -05:00
|
|
|
mail_answer_thread(issue, issue_thread_options(updated_by_user.id, recipient.id, reason))
|
2016-03-15 06:35:40 -04:00
|
|
|
end
|
|
|
|
|
2015-11-17 05:55:43 -05:00
|
|
|
private
|
|
|
|
|
2016-03-15 12:24:55 -04:00
|
|
|
def setup_issue_mail(issue_id, recipient_id)
|
2016-03-01 11:33:13 -05:00
|
|
|
@issue = Issue.find(issue_id)
|
|
|
|
@project = @issue.project
|
2017-06-29 13:06:35 -04:00
|
|
|
@target_url = project_issue_url(@project, @issue)
|
2016-03-01 11:33:13 -05:00
|
|
|
|
2016-03-15 12:24:55 -04:00
|
|
|
@sent_notification = SentNotification.record(@issue, recipient_id, reply_key)
|
2016-03-01 11:33:13 -05:00
|
|
|
end
|
|
|
|
|
2017-12-28 12:25:02 -05:00
|
|
|
def issue_thread_options(sender_id, recipient_id, reason)
|
2015-11-16 17:53:21 -05:00
|
|
|
{
|
|
|
|
from: sender(sender_id),
|
|
|
|
to: recipient(recipient_id),
|
2017-12-28 12:25:02 -05:00
|
|
|
subject: subject("#{@issue.title} (##{@issue.iid})"),
|
|
|
|
'X-GitLab-NotificationReason' => reason
|
2015-11-16 17:53:21 -05:00
|
|
|
}
|
|
|
|
end
|
2013-03-19 14:00:41 -04:00
|
|
|
end
|
|
|
|
end
|