Module: Emails::Issues

Included in:
Notify
Defined in:
app/mailers/emails/issues.rb

Instance Method Summary collapse

Instance Method Details

#changed_milestone_issue_email(recipient_id, issue_id, milestone, updated_by_user_id, reason = nil) ⇒ Object


56
57
58
59
60
61
62
63
64
# File 'app/mailers/emails/issues.rb', line 56

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)
  mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason).merge({
    template_name: 'changed_milestone_email'
  }))
end

#closed_issue_email(recipient_id, issue_id, updated_by_user_id, reason: nil, closed_via: nil) ⇒ Object

rubocop: enable CodeReuse/ActiveRecord


33
34
35
36
37
38
39
40
# File 'app/mailers/emails/issues.rb', line 33

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)

  @updated_by = User.find(updated_by_user_id)
  @recipient = User.find(recipient_id)

  mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
end

#import_issues_csv_email(user_id, project_id, results) ⇒ Object


83
84
85
86
87
88
89
90
91
92
# File 'app/mailers/emails/issues.rb', line 83

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_for(@project.group), subject: subject('Imported issues')) do |format|
    format.html { render layout: 'mailer' }
    format.text { render layout: 'mailer' }
  end
end

#issue_due_email(recipient_id, issue_id, reason = nil) ⇒ Object


11
12
13
14
15
# File 'app/mailers/emails/issues.rb', line 11

def issue_due_email(recipient_id, issue_id, reason = nil)
  setup_issue_mail(issue_id, recipient_id)

  mail_answer_thread(@issue, issue_thread_options(@issue.author_id, recipient_id, reason))
end

#issue_moved_email(recipient, issue, new_issue, updated_by_user, reason = nil) ⇒ Object


74
75
76
77
78
79
80
81
# File 'app/mailers/emails/issues.rb', line 74

def issue_moved_email(recipient, issue, new_issue, updated_by_user, reason = nil)
  setup_issue_mail(issue.id, recipient.id)

  @new_issue = new_issue
  @new_project = new_issue.project
  @can_access_project = recipient.can?(:read_project, @new_project)
  mail_answer_thread(issue, issue_thread_options(updated_by_user.id, recipient.id, reason))
end

#issue_status_changed_email(recipient_id, issue_id, status, updated_by_user_id, reason = nil) ⇒ Object


66
67
68
69
70
71
72
# File 'app/mailers/emails/issues.rb', line 66

def issue_status_changed_email(recipient_id, issue_id, status, updated_by_user_id, reason = nil)
  setup_issue_mail(issue_id, recipient_id)

  @issue_status = status
  @updated_by = User.find(updated_by_user_id)
  mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
end

#issues_csv_email(user, project, csv_data, export_status) ⇒ Object


94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'app/mailers/emails/issues.rb', line 94

def issues_csv_email(user, project, csv_data, export_status)
  @project = project
  @issues_count = export_status.fetch(:rows_expected)
  @written_count = export_status.fetch(:rows_written)
  @truncated = export_status.fetch(:truncated)

  filename = "#{project.full_path.parameterize}_issues_#{Date.today.iso8601}.csv"
  attachments[filename] = { content: csv_data, mime_type: 'text/csv' }
  mail(to: user.notification_email_for(@project.group), subject: subject("Exported issues")) do |format|
    format.html { render layout: 'mailer' }
    format.text { render layout: 'mailer' }
  end
end

#new_issue_email(recipient_id, issue_id, reason = nil) ⇒ Object


5
6
7
8
9
# File 'app/mailers/emails/issues.rb', line 5

def new_issue_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

#new_mention_in_issue_email(recipient_id, issue_id, updated_by_user_id, reason = nil) ⇒ Object


17
18
19
20
# File 'app/mailers/emails/issues.rb', line 17

def new_mention_in_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

#reassigned_issue_email(recipient_id, issue_id, previous_assignee_ids, updated_by_user_id, reason = nil) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


23
24
25
26
27
28
29
30
# File 'app/mailers/emails/issues.rb', line 23

def reassigned_issue_email(recipient_id, issue_id, previous_assignee_ids, updated_by_user_id, reason = nil)
  setup_issue_mail(issue_id, recipient_id)

  @previous_assignees = []
  @previous_assignees = User.where(id: previous_assignee_ids) if previous_assignee_ids.any?

  mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
end

#relabeled_issue_email(recipient_id, issue_id, label_names, updated_by_user_id, reason = nil) ⇒ Object


42
43
44
45
46
47
48
# File 'app/mailers/emails/issues.rb', line 42

def relabeled_issue_email(recipient_id, issue_id, label_names, updated_by_user_id, reason = nil)
  setup_issue_mail(issue_id, recipient_id)

  @label_names = label_names
  @labels_url = project_labels_url(@project)
  mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
end

#removed_milestone_issue_email(recipient_id, issue_id, updated_by_user_id, reason = nil) ⇒ Object


50
51
52
53
54
# File 'app/mailers/emails/issues.rb', line 50

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