BigW Consortium Gitlab

issues.rb 2.24 KB
Newer Older
1 2
module Emails
  module Issues
3
    def new_issue_email(recipient_id, issue_id)
4 5 6
      setup_issue_mail(issue_id, recipient_id)

      mail_new_thread(@issue, issue_thread_options(@issue.author_id, recipient_id))
7 8
    end

9
    def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id, updated_by_user_id)
10 11 12 13
      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))
14 15
    end

16
    def closed_issue_email(recipient_id, issue_id, updated_by_user_id)
17 18
      setup_issue_mail(issue_id, recipient_id)

19 20 21 22
      @updated_by = User.find(updated_by_user_id)
      mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id))
    end

23
    def relabeled_issue_email(recipient_id, issue_id, label_names, updated_by_user_id)
24
      setup_issue_mail(issue_id, recipient_id)
25

26
      @label_names = label_names
27
      @labels_url = namespace_project_labels_url(@project.namespace, @project)
28
      mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id))
29 30
    end

31
    def issue_status_changed_email(recipient_id, issue_id, status, updated_by_user_id)
32 33 34
      setup_issue_mail(issue_id, recipient_id)

      @issue_status = status
35
      @updated_by = User.find(updated_by_user_id)
36
      mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id))
37 38
    end

39 40 41 42 43 44 45 46
    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

47 48
    private

49
    def setup_issue_mail(issue_id, recipient_id)
50 51 52 53
      @issue = Issue.find(issue_id)
      @project = @issue.project
      @target_url = namespace_project_issue_url(@project.namespace, @project, @issue)

54
      @sent_notification = SentNotification.record(@issue, recipient_id, reply_key)
55 56
    end

57
    def issue_thread_options(sender_id, recipient_id)
58 59 60 61 62 63
      {
        from: sender(sender_id),
        to: recipient(recipient_id),
        subject: subject("#{@issue.title} (##{@issue.iid})")
      }
    end
64 65
  end
end