summaryrefslogtreecommitdiff
path: root/app/mailers
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2018-12-05 12:22:52 -0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2018-12-11 23:08:17 -0300
commitb65cb237cee0b1a8dfdc21a09f2b181d0edf5bde (patch)
treedffc212c6e7ca84c1e61ec1625e53548c0b6de18 /app/mailers
parent80eebd8e33c5f2f26bc0fdd233d9d92c51edd242 (diff)
downloadgitlab-ce-b65cb237cee0b1a8dfdc21a09f2b181d0edf5bde.tar.gz
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.
Diffstat (limited to 'app/mailers')
-rw-r--r--app/mailers/emails/remote_mirrors.rb12
-rw-r--r--app/mailers/notify.rb1
-rw-r--r--app/mailers/previews/notify_preview.rb8
3 files changed, 21 insertions, 0 deletions
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