diff options
Diffstat (limited to 'app/mailers')
-rw-r--r-- | app/mailers/emails/in_product_marketing.rb | 4 | ||||
-rw-r--r-- | app/mailers/emails/issues.rb | 28 | ||||
-rw-r--r-- | app/mailers/emails/members.rb | 29 | ||||
-rw-r--r-- | app/mailers/emails/merge_requests.rb | 47 | ||||
-rw-r--r-- | app/mailers/emails/notes.rb | 15 | ||||
-rw-r--r-- | app/mailers/emails/projects.rb | 8 | ||||
-rw-r--r-- | app/mailers/emails/releases.rb | 5 |
7 files changed, 60 insertions, 76 deletions
diff --git a/app/mailers/emails/in_product_marketing.rb b/app/mailers/emails/in_product_marketing.rb index e745cd51a55..317e1545350 100644 --- a/app/mailers/emails/in_product_marketing.rb +++ b/app/mailers/emails/in_product_marketing.rb @@ -29,7 +29,7 @@ module Emails format.html do @message.format = :html - render layout: nil + render layout: 'in_product_marketing_mailer' end format.text do @@ -41,3 +41,5 @@ module Emails end end end + +Emails::InProductMarketing.prepend_mod diff --git a/app/mailers/emails/issues.rb b/app/mailers/emails/issues.rb index 51c4779d8cf..bbc4be3b324 100644 --- a/app/mailers/emails/issues.rb +++ b/app/mailers/emails/issues.rb @@ -5,18 +5,18 @@ module Emails 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)) + mail_new_thread(@issue, issue_thread_options(@issue.author_id, reason)) end 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)) + mail_answer_thread(@issue, issue_thread_options(@issue.author_id, reason)) end 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)) + mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, reason)) end # rubocop: disable CodeReuse/ActiveRecord @@ -26,7 +26,7 @@ module Emails @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)) + mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, reason)) end # rubocop: enable CodeReuse/ActiveRecord @@ -34,9 +34,8 @@ module Emails 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)) + mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, reason)) end def relabeled_issue_email(recipient_id, issue_id, label_names, updated_by_user_id, reason = nil) @@ -44,13 +43,13 @@ module Emails @label_names = label_names @labels_url = project_labels_url(@project) - mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason)) + mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, reason)) end 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)) + mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, reason)) end def changed_milestone_issue_email(recipient_id, issue_id, milestone, updated_by_user_id, reason = nil) @@ -58,7 +57,7 @@ module Emails @milestone = milestone @milestone_url = milestone_url(@milestone) - mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason).merge({ + mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, reason).merge({ template_name: 'changed_milestone_email' })) end @@ -68,7 +67,7 @@ module Emails @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)) + mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, reason)) end def issue_moved_email(recipient, issue, new_issue, updated_by_user, reason = nil) @@ -77,7 +76,7 @@ module Emails @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)) + mail_answer_thread(issue, issue_thread_options(updated_by_user.id, reason)) end def issue_cloned_email(recipient, issue, new_issue, updated_by_user, reason = nil) @@ -87,7 +86,7 @@ module Emails @issue = issue @new_issue = new_issue @can_access_project = recipient.can?(:read_project, @new_issue.project) - mail_answer_thread(issue, issue_thread_options(updated_by_user.id, recipient.id, reason)) + mail_answer_thread(issue, issue_thread_options(updated_by_user.id, reason)) end def import_issues_csv_email(user_id, project_id, results) @@ -124,14 +123,15 @@ module Emails @project = @issue.project @target_url = project_issue_url(@project, @issue) @closed_via = closed_via + @recipient = User.find(recipient_id) @sent_notification = SentNotification.record(@issue, recipient_id, reply_key) end - def issue_thread_options(sender_id, recipient_id, reason) + def issue_thread_options(sender_id, reason) { from: sender(sender_id), - to: User.find(recipient_id).notification_email_for(@project.group), + to: @recipient.notification_email_for(@project.group), subject: subject("#{@issue.title} (##{@issue.iid})"), 'X-GitLab-NotificationReason' => reason } diff --git a/app/mailers/emails/members.rb b/app/mailers/emails/members.rb index 8a9ed557cc6..ef2220751bf 100644 --- a/app/mailers/emails/members.rb +++ b/app/mailers/emails/members.rb @@ -61,7 +61,7 @@ module Emails Gitlab::Tracking.event(self.class.name, 'invite_email_sent', label: 'invite_email', property: member_id.to_s) - mail(to: member.invite_email, subject: invite_email_subject, **invite_email_headers.merge(additional_invite_settings)) do |format| + mail(to: member.invite_email, subject: invite_email_subject, **invite_email_headers) do |format| format.html { render layout: 'unknown_user_mailer' } format.text { render layout: 'unknown_user_mailer' } end @@ -151,17 +151,7 @@ module Emails def invite_email_subject if member.created_by - experiment(:invite_email_from, actor: member) do |experiment_instance| - experiment_instance.use do - subject(s_("MemberInviteEmail|%{member_name} invited you to join GitLab") % { member_name: member.created_by.name }) - end - - experiment_instance.candidate do - subject(s_("MemberInviteEmail|I've invited you to join me in GitLab")) - end - - experiment_instance.run - end + subject(s_("MemberInviteEmail|%{member_name} invited you to join GitLab") % { member_name: member.created_by.name }) else subject(s_("MemberInviteEmail|Invitation to join the %{project_or_group} %{project_or_group_name}") % { project_or_group: member_source.human_name, project_or_group_name: member_source.model_name.singular }) end @@ -178,21 +168,6 @@ module Emails end end - def additional_invite_settings - return {} unless member.created_by - - experiment(:invite_email_from, actor: member) do |experiment_instance| - experiment_instance.use { {} } - experiment_instance.candidate do - { - from: "#{member.created_by.name} <#{member.created_by.email}>" - } - end - - experiment_instance.run - end - end - def member_exists? Gitlab::AppLogger.info("Tried to send an email invitation for a deleted group. Member id: #{@member_id}") if member.blank? member.present? diff --git a/app/mailers/emails/merge_requests.rb b/app/mailers/emails/merge_requests.rb index 2746b8b7188..d2e710cc329 100644 --- a/app/mailers/emails/merge_requests.rb +++ b/app/mailers/emails/merge_requests.rb @@ -5,13 +5,13 @@ module Emails 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, recipient_id, reason)) + mail_new_thread(@merge_request, merge_request_thread_options(@merge_request.author_id, reason)) end 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, recipient_id, reason)) + mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason)) end def push_to_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil, new_commits: [], existing_commits: []) @@ -20,7 +20,7 @@ module Emails @existing_commits = existing_commits @updated_by_user = User.find(updated_by_user_id) - mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason)) + mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason)) end def change_in_merge_request_draft_status_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil) @@ -28,7 +28,7 @@ module Emails @updated_by_user = User.find(updated_by_user_id) - mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason)) + mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason)) end # rubocop: disable CodeReuse/ActiveRecord @@ -38,7 +38,7 @@ module Emails @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, recipient_id, reason)) + mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason)) end # rubocop: enable CodeReuse/ActiveRecord @@ -49,7 +49,7 @@ module Emails @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, recipient_id, reason)) + mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason)) end # rubocop: enable CodeReuse/ActiveRecord @@ -58,13 +58,13 @@ module Emails @label_names = label_names @labels_url = project_labels_url(@project) - mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason)) + mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason)) end 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, recipient_id, reason)) + mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason)) end def changed_milestone_merge_request_email(recipient_id, merge_request_id, milestone, updated_by_user_id, reason = nil) @@ -72,7 +72,7 @@ module Emails @milestone = milestone @milestone_url = milestone_url(@milestone) - mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason).merge({ + mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason).merge({ template_name: 'changed_milestone_email' })) end @@ -81,20 +81,27 @@ module Emails 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, recipient_id, reason)) + mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason)) end 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, recipient_id, reason)) + mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason)) end 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, recipient_id, reason)) + mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason)) + end + + 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 def merge_request_status_email(recipient_id, merge_request_id, status, updated_by_user_id, reason = nil) @@ -102,27 +109,27 @@ module Emails @mr_status = status @updated_by = User.find(updated_by_user_id) - mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason)) + mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, reason)) end 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, recipient_id, reason)) + mail_answer_thread(@merge_request, merge_request_thread_options(@merge_request.author_id, reason)) end 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, recipient_id, reason)) + mail_answer_thread(@merge_request, merge_request_thread_options(resolved_by_user_id, reason)) end 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, recipient_id, reason)) + mail_answer_thread(@merge_request, merge_request_thread_options(mwps_set_by_user_id, reason)) end def merge_requests_csv_email(user, project, csv_data, export_status) @@ -147,19 +154,19 @@ module Emails @merge_request = MergeRequest.find(merge_request_id) @project = @merge_request.project @target_url = project_merge_request_url(@project, @merge_request) + @recipient = User.find(recipient_id) if present - recipient = User.find(recipient_id) - @mr_presenter = @merge_request.present(current_user: recipient) + @mr_presenter = @merge_request.present(current_user: @recipient) end @sent_notification = SentNotification.record(@merge_request, recipient_id, reply_key) end - def merge_request_thread_options(sender_id, recipient_id, reason = nil) + def merge_request_thread_options(sender_id, reason = nil) { from: sender(sender_id), - to: User.find(recipient_id).notification_email_for(@project.group), + to: @recipient.notification_email_for(@project.group), subject: subject("#{@merge_request.title} (#{@merge_request.to_reference})"), 'X-GitLab-NotificationReason' => reason } diff --git a/app/mailers/emails/notes.rb b/app/mailers/emails/notes.rb index 587c1479286..1e254a32885 100644 --- a/app/mailers/emails/notes.rb +++ b/app/mailers/emails/notes.rb @@ -7,7 +7,7 @@ module Emails @commit = @note.noteable @target_url = project_commit_url(*note_target_url_options) - mail_answer_note_thread(@commit, @note, note_thread_options(recipient_id, reason)) + mail_answer_note_thread(@commit, @note, note_thread_options(reason)) end def note_issue_email(recipient_id, note_id, reason = nil) @@ -15,7 +15,7 @@ module Emails @issue = @note.noteable @target_url = project_issue_url(*note_target_url_options) - mail_answer_note_thread(@issue, @note, note_thread_options(recipient_id, reason)) + mail_answer_note_thread(@issue, @note, note_thread_options(reason)) end def note_merge_request_email(recipient_id, note_id, reason = nil) @@ -23,7 +23,7 @@ module Emails @merge_request = @note.noteable @target_url = project_merge_request_url(*note_target_url_options) - mail_answer_note_thread(@merge_request, @note, note_thread_options(recipient_id, reason)) + mail_answer_note_thread(@merge_request, @note, note_thread_options(reason)) end def note_snippet_email(recipient_id, note_id, reason = nil) @@ -37,7 +37,7 @@ module Emails @target_url = gitlab_snippet_url(@note.noteable) end - mail_answer_note_thread(@snippet, @note, note_thread_options(recipient_id, reason)) + mail_answer_note_thread(@snippet, @note, note_thread_options(reason)) end def note_design_email(recipient_id, note_id, reason = nil) @@ -49,7 +49,7 @@ module Emails design.issue, note_target_url_query_params.merge(vueroute: design.filename) ) - mail_answer_note_thread(design, @note, note_thread_options(recipient_id, reason)) + mail_answer_note_thread(design, @note, note_thread_options(reason)) end private @@ -62,10 +62,10 @@ module Emails { anchor: "note_#{@note.id}" } end - def note_thread_options(recipient_id, reason) + def note_thread_options(reason) { from: sender(@note.author_id), - to: User.find(recipient_id).notification_email_for(@project&.group || @group), + to: @recipient.notification_email_for(@project&.group || @group), subject: subject("#{@note.noteable.title} (#{@note.noteable.reference_link_text})"), 'X-GitLab-NotificationReason' => reason } @@ -76,6 +76,7 @@ module Emails @note = note_id.is_a?(Note) ? note_id : Note.find(note_id) @project = @note.project @group = @note.noteable.try(:group) + @recipient = User.find(recipient_id) if (@project || @group) && @note.persisted? @sent_notification = SentNotification.record_note(@note, recipient_id, reply_key) diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb index 06ba16f9724..14c724b5b91 100644 --- a/app/mailers/emails/projects.rb +++ b/app/mailers/emails/projects.rb @@ -59,6 +59,7 @@ module Emails def prometheus_alert_fired_email(project, user, alert) @project = project @alert = alert.present + @incident = alert.issue add_project_headers add_alert_headers @@ -80,11 +81,10 @@ module Emails end def add_incident_headers - incident = @alert.issue - return unless incident + return unless @incident - headers['X-GitLab-Incident-ID'] = incident.id - headers['X-GitLab-Incident-IID'] = incident.iid + headers['X-GitLab-Incident-ID'] = @incident.id + headers['X-GitLab-Incident-IID'] = @incident.iid end end end diff --git a/app/mailers/emails/releases.rb b/app/mailers/emails/releases.rb index c9c77ab9333..4875abafe8d 100644 --- a/app/mailers/emails/releases.rb +++ b/app/mailers/emails/releases.rb @@ -9,11 +9,10 @@ module Emails namespace_id: @project.namespace, project_id: @project ) - - user = User.find(user_id) + @recipient = User.find(user_id) mail( - to: user.notification_email_for(@project.group), + to: @recipient.notification_email_for(@project.group), subject: subject(release_email_subject) ) end |