Commit 249d08c2 authored by Wei-Meng Lee's avatar Wei-Meng Lee

Route notifications to groups for EE mailers

parent e03b7728
......@@ -5,24 +5,21 @@ module EE
module Projects
def mirror_was_hard_failed_email(project_id, user_id)
@project = ::Project.find(project_id)
user = ::User.find(user_id)
mail(to: user.notification_email,
mail(to: recipient(user_id, @project.group),
subject: subject('Repository mirroring paused'))
end
def project_mirror_user_changed_email(new_mirror_user_id, deleted_user_name, project_id)
@project = ::Project.find(project_id)
@deleted_user_name = deleted_user_name
new_mirror_user = ::User.find(new_mirror_user_id)
mail(to: new_mirror_user.notification_email,
mail(to: recipient(new_mirror_user_id, @project.group),
subject: subject('Mirror user changed'))
end
def prometheus_alert_fired_email(project_id, user_id, alert_payload)
@project = ::Project.find(project_id)
user = ::User.find(user_id)
@alert = ::Gitlab::Alerting::Alert
.new(project: @project, payload: alert_payload)
......@@ -30,7 +27,7 @@ module EE
return unless @alert.valid?
subject_text = "Alert: #{@alert.email_subject}"
mail(to: user.notification_email, subject: subject(subject_text))
mail(to: recipient(user_id, @project.group), subject: subject(subject_text))
end
end
end
......
......@@ -10,7 +10,7 @@ module Emails
filename = "#{project.full_path.parameterize}_issues_#{Date.today.iso8601}.csv"
attachments[filename] = { content: csv_data, mime_type: 'text/csv' }
mail(to: user.notification_email, subject: subject("Exported issues")) do |format|
mail(to: recipient(user.id, @project.group), subject: subject("Exported issues")) do |format|
format.html { render layout: 'mailer' }
format.text { render layout: 'mailer' }
end
......
......@@ -35,7 +35,7 @@ module Emails
def epic_thread_options(sender_id, recipient_id, reason)
{
from: sender(sender_id),
to: recipient(recipient_id),
to: recipient(recipient_id, @epic.group),
subject: subject("#{@epic.title} (#{@epic.to_reference})"),
'X-GitLab-NotificationReason' => reason
}
......
......@@ -13,7 +13,7 @@ module Emails
def review_thread_options(recipient_id)
{
from: sender(@author.id),
to: recipient(recipient_id),
to: recipient(recipient_id, @merge_request.target_project.group),
subject: subject("#{@merge_request.title} (#{@merge_request.to_reference})")
}
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment