diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-03 21:11:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-03 21:11:11 +0300 |
commit | 5b0916450cebb6a88bd651fd0579737541c355c8 (patch) | |
tree | 3a788fd8e2ef18b1c6e06d222e84bb5d84307870 /app/mailers | |
parent | 78aaabb87f180e93fa53aba407a0eef1e12a7a56 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/mailers')
-rw-r--r-- | app/mailers/emails/issues.rb | 28 | ||||
-rw-r--r-- | app/mailers/emails/merge_requests.rb | 42 | ||||
-rw-r--r-- | app/mailers/emails/notes.rb | 15 | ||||
-rw-r--r-- | app/mailers/emails/releases.rb | 5 |
4 files changed, 45 insertions, 45 deletions
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/merge_requests.rb b/app/mailers/emails/merge_requests.rb index 3dfc8136d45..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,27 +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, recipient_id, reason)) + 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) @@ -109,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) @@ -154,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/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 |