2013-03-19 14:00:41 -04:00
|
|
|
module Emails
|
|
|
|
module Issues
|
2013-03-28 06:52:44 -04:00
|
|
|
def new_issue_email(recipient_id, issue_id)
|
2015-12-09 05:59:25 -05:00
|
|
|
setup_issue_mail(issue_id, recipient_id)
|
|
|
|
|
|
|
|
mail_new_thread(@issue, issue_thread_options(@issue.author_id, recipient_id))
|
2013-03-19 14:00:41 -04:00
|
|
|
end
|
|
|
|
|
2014-02-17 12:49:42 -05:00
|
|
|
def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id, updated_by_user_id)
|
2015-12-09 05:59:25 -05:00
|
|
|
setup_issue_mail(issue_id, recipient_id)
|
|
|
|
|
|
|
|
@previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id
|
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id))
|
2013-03-19 14:00:41 -04:00
|
|
|
end
|
|
|
|
|
2013-03-28 06:24:04 -04:00
|
|
|
def closed_issue_email(recipient_id, issue_id, updated_by_user_id)
|
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)
|
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id))
|
|
|
|
end
|
|
|
|
|
2016-03-01 11:33:13 -05:00
|
|
|
def relabeled_issue_email(recipient_id, issue_id, label_names, updated_by_user_id)
|
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
|
2016-03-01 11:33:13 -05:00
|
|
|
@labels_url = namespace_project_labels_url(@project.namespace, @project)
|
2015-12-09 05:59:25 -05:00
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id))
|
2013-03-28 06:14:53 -04:00
|
|
|
end
|
|
|
|
|
2013-03-19 14:00:41 -04:00
|
|
|
def issue_status_changed_email(recipient_id, issue_id, status, updated_by_user_id)
|
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)
|
2015-12-09 05:59:25 -05:00
|
|
|
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id))
|
2015-11-16 17:53:21 -05:00
|
|
|
end
|
|
|
|
|
2016-03-15 06:35:40 -04:00
|
|
|
def issue_moved_email(recipient, issue, new_issue, updated_by_user)
|
|
|
|
setup_issue_mail(issue.id, recipient.id)
|
|
|
|
|
|
|
|
@new_issue = new_issue
|
|
|
|
@new_project = new_issue.project
|
|
|
|
mail_answer_thread(issue, issue_thread_options(updated_by_user.id, recipient.id))
|
|
|
|
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
|
|
|
|
@target_url = namespace_project_issue_url(@project.namespace, @project, @issue)
|
|
|
|
|
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
|
|
|
|
|
2015-11-17 05:55:43 -05:00
|
|
|
def issue_thread_options(sender_id, recipient_id)
|
2015-11-16 17:53:21 -05:00
|
|
|
{
|
|
|
|
from: sender(sender_id),
|
|
|
|
to: recipient(recipient_id),
|
|
|
|
subject: subject("#{@issue.title} (##{@issue.iid})")
|
|
|
|
}
|
|
|
|
end
|
2013-03-19 14:00:41 -04:00
|
|
|
end
|
|
|
|
end
|