From b65cb237cee0b1a8dfdc21a09f2b181d0edf5bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rodr=C3=ADguez?= Date: Wed, 5 Dec 2018 12:22:52 -0300 Subject: Send a notification email on mirror update errors The email is sent to project maintainers containing the last mirror update error. This will allow maintainers to set alarms and react accordingly. --- app/mailers/emails/remote_mirrors.rb | 12 ++++++++++++ app/mailers/notify.rb | 1 + app/mailers/previews/notify_preview.rb | 8 ++++++++ 3 files changed, 21 insertions(+) create mode 100644 app/mailers/emails/remote_mirrors.rb (limited to 'app/mailers') diff --git a/app/mailers/emails/remote_mirrors.rb b/app/mailers/emails/remote_mirrors.rb new file mode 100644 index 00000000000..2018eb7260b --- /dev/null +++ b/app/mailers/emails/remote_mirrors.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Emails + module RemoteMirrors + def remote_mirror_update_failed_email(remote_mirror_id, recipient_id) + @remote_mirror = RemoteMirrorFinder.new(id: remote_mirror_id).execute + @project = @remote_mirror.project + + mail(to: recipient(recipient_id), subject: subject('Remote mirror update failed')) + end + end +end diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 88ad4c3e893..099ad779aa5 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -13,6 +13,7 @@ class Notify < BaseMailer include Emails::Pipelines include Emails::Members include Emails::AutoDevops + include Emails::RemoteMirrors helper MergeRequestsHelper helper DiffHelper diff --git a/app/mailers/previews/notify_preview.rb b/app/mailers/previews/notify_preview.rb index e7e8d96eca4..2ac4610967d 100644 --- a/app/mailers/previews/notify_preview.rb +++ b/app/mailers/previews/notify_preview.rb @@ -145,6 +145,10 @@ class NotifyPreview < ActionMailer::Preview Notify.autodevops_disabled_email(pipeline, user.email).message end + def remote_mirror_update_failed_email + Notify.remote_mirror_update_failed_email(remote_mirror.id, user.id).message + end + private def project @@ -167,6 +171,10 @@ class NotifyPreview < ActionMailer::Preview @pipeline = Ci::Pipeline.last end + def remote_mirror + @remote_mirror ||= RemoteMirror.last + end + def user @user ||= User.last end -- cgit v1.2.3