Module: Emails::MergeRequests

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

Instance Method Summary collapse

Instance Method Details

#approved_merge_request_email(recipient_id, merge_request_id, approved_by_user_id, reason = nil) ⇒ Object


158
159
160
161
162
163
# File 'app/mailers/emails/merge_requests.rb', line 158

def approved_merge_request_email(recipient_id, merge_request_id, approved_by_user_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  @approved_by = User.find(approved_by_user_id)
  mail_answer_thread(@merge_request, merge_request_thread_options(approved_by_user_id, reason))
end

#attention_requested_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil) ⇒ Object


107
108
109
110
111
112
# File 'app/mailers/emails/merge_requests.rb', line 107

def attention_requested_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  @updated_by = User.find(updated_by_user_id)
  mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason))
end

#change_in_merge_request_draft_status_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil) ⇒ Object


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

def change_in_merge_request_draft_status_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  @updated_by_user = User.find(updated_by_user_id)

  mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason))
end

#changed_milestone_merge_request_email(recipient_id, merge_request_id, milestone, updated_by_user_id, reason = nil) ⇒ Object


77
78
79
80
81
82
83
84
85
# File 'app/mailers/emails/merge_requests.rb', line 77

def changed_milestone_merge_request_email(recipient_id, merge_request_id, milestone, updated_by_user_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  @milestone = milestone
  @milestone_url = milestone_url(@milestone)
  mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason).merge({
    template_name: 'changed_milestone_email'
  }))
end

#changed_reviewer_of_merge_request_email(recipient_id, merge_request_id, previous_reviewer_ids, updated_by_user_id, reason = nil) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


53
54
55
56
57
58
59
60
# File 'app/mailers/emails/merge_requests.rb', line 53

def changed_reviewer_of_merge_request_email(recipient_id, merge_request_id, previous_reviewer_ids, updated_by_user_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  @previous_reviewers = []
  @previous_reviewers = User.where(id: previous_reviewer_ids) if previous_reviewer_ids.any?

  mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason))
end

#closed_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason: nil, closed_via: nil) ⇒ Object


87
88
89
90
91
92
# File 'app/mailers/emails/merge_requests.rb', line 87

def closed_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason: nil, closed_via: nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  @updated_by = User.find(updated_by_user_id)
  mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason))
end

#merge_request_status_email(recipient_id, merge_request_id, status, updated_by_user_id, reason = nil) ⇒ Object


114
115
116
117
118
119
120
# File 'app/mailers/emails/merge_requests.rb', line 114

def merge_request_status_email(recipient_id, merge_request_id, status, updated_by_user_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  @mr_status = status
  @updated_by = User.find(updated_by_user_id)
  mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason))
end

#merge_request_unmergeable_email(recipient_id, merge_request_id, reason = nil) ⇒ Object


122
123
124
125
126
# File 'app/mailers/emails/merge_requests.rb', line 122

def merge_request_unmergeable_email(recipient_id, merge_request_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  mail_answer_thread(@merge_request, merge_request_thread_options(@merge_request.author_id, reason))
end

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


142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'app/mailers/emails/merge_requests.rb', line 142

def merge_requests_csv_email(user, project, csv_data, export_status)
  @project = project
  @count = export_status.fetch(:rows_expected)
  @written_count = export_status.fetch(:rows_written)
  @truncated = export_status.fetch(:truncated)
  @size_limit = ActiveSupport::NumberHelper
    .number_to_human_size(Issuable::ExportCsv::BaseService::TARGET_FILESIZE)

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

#merge_when_pipeline_succeeds_email(recipient_id, merge_request_id, mwps_set_by_user_id, reason = nil) ⇒ Object


135
136
137
138
139
140
# File 'app/mailers/emails/merge_requests.rb', line 135

def merge_when_pipeline_succeeds_email(recipient_id, merge_request_id, mwps_set_by_user_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  @mwps_set_by = ::User.find(mwps_set_by_user_id)
  mail_answer_thread(@merge_request, merge_request_thread_options(mwps_set_by_user_id, reason))
end

#merged_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason: nil, closed_via: nil) ⇒ Object


94
95
96
97
98
# File 'app/mailers/emails/merge_requests.rb', line 94

def merged_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason: nil, closed_via: nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason))
end

#new_mention_in_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil) ⇒ Object


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

def new_mention_in_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id, present: true)

  mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason))
end

#new_merge_request_email(recipient_id, merge_request_id, reason = nil) ⇒ Object


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

def new_merge_request_email(recipient_id, merge_request_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id, present: true)

  mail_new_thread(@merge_request, merge_request_thread_options(@merge_request.author_id, reason))
end

#push_to_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil, new_commits: [], total_new_commits_count: nil, existing_commits: [], total_existing_commits_count: nil) ⇒ Object

existing_commits - an array containing the first and last commits


18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/mailers/emails/merge_requests.rb', line 18

def push_to_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil, new_commits: [], total_new_commits_count: nil, existing_commits: [], total_existing_commits_count: nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  @new_commits = new_commits
  @total_new_commits_count = total_new_commits_count || @new_commits.length
  @total_stripped_new_commits_count = @total_new_commits_count - @new_commits.length

  @existing_commits = existing_commits
  @total_existing_commits_count = total_existing_commits_count || @existing_commits.length

  @updated_by_user = User.find(updated_by_user_id)

  mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason))
end

#reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_ids, updated_by_user_id, reason = nil) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


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

def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_ids, updated_by_user_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

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

  mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason))
end

#relabeled_merge_request_email(recipient_id, merge_request_id, label_names, updated_by_user_id, reason = nil) ⇒ Object

rubocop: enable CodeReuse/ActiveRecord


63
64
65
66
67
68
69
# File 'app/mailers/emails/merge_requests.rb', line 63

def relabeled_merge_request_email(recipient_id, merge_request_id, label_names, updated_by_user_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  @label_names = label_names
  @labels_url = project_labels_url(@project)
  mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason))
end

#removed_milestone_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil) ⇒ Object


71
72
73
74
75
# File 'app/mailers/emails/merge_requests.rb', line 71

def removed_milestone_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason))
end

#request_review_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil) ⇒ Object


100
101
102
103
104
105
# File 'app/mailers/emails/merge_requests.rb', line 100

def request_review_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  @updated_by = User.find(updated_by_user_id)
  mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason))
end

#resolved_all_discussions_email(recipient_id, merge_request_id, resolved_by_user_id, reason = nil) ⇒ Object


128
129
130
131
132
133
# File 'app/mailers/emails/merge_requests.rb', line 128

def resolved_all_discussions_email(recipient_id, merge_request_id, resolved_by_user_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  @resolved_by = User.find(resolved_by_user_id)
  mail_answer_thread(@merge_request, merge_request_thread_options(resolved_by_user_id, reason))
end

#unapproved_merge_request_email(recipient_id, merge_request_id, unapproved_by_user_id, reason = nil) ⇒ Object


165
166
167
168
169
170
# File 'app/mailers/emails/merge_requests.rb', line 165

def unapproved_merge_request_email(recipient_id, merge_request_id, unapproved_by_user_id, reason = nil)
  setup_merge_request_mail(merge_request_id, recipient_id)

  @unapproved_by = User.find(unapproved_by_user_id)
  mail_answer_thread(@merge_request, merge_request_thread_options(unapproved_by_user_id, reason))
end