about summary refs log tree commit diff
path: root/app/mailers
diff options
context:
space:
mode:
authorbeatrix-bitrot <beatrix.bitrot@gmail.com>2017-06-27 20:46:13 +0000
committerbeatrix-bitrot <beatrix.bitrot@gmail.com>2017-06-27 20:46:13 +0000
commitddafde942ca53816c19b0ea0cb40bb1b46cf5668 (patch)
treec0ac2138fe994c4c2a15c23b47d4155f75148945 /app/mailers
parente6300de1421d28d173658e61601b9e016c3d0a6d (diff)
parentda42bfadb58888e3a18afd66395f0f3edc2fa622 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'app/mailers')
-rw-r--r--app/mailers/admin_mailer.rb13
-rw-r--r--app/mailers/application_mailer.rb8
-rw-r--r--app/mailers/notification_mailer.rb8
3 files changed, 21 insertions, 8 deletions
diff --git a/app/mailers/admin_mailer.rb b/app/mailers/admin_mailer.rb
new file mode 100644
index 000000000..fc19a6d40
--- /dev/null
+++ b/app/mailers/admin_mailer.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class AdminMailer < ApplicationMailer
+  def new_report(recipient, report)
+    @report   = report
+    @me       = recipient
+    @instance = Rails.configuration.x.local_domain
+
+    locale_for_account(@me) do
+      mail to: @me.user_email, subject: I18n.t('admin_mailer.new_report.subject', instance: @instance, id: @report.id)
+    end
+  end
+end
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
index e5dbfeeda..2e730c19b 100644
--- a/app/mailers/application_mailer.rb
+++ b/app/mailers/application_mailer.rb
@@ -4,4 +4,12 @@ class ApplicationMailer < ActionMailer::Base
   default from: ENV.fetch('SMTP_FROM_ADDRESS') { 'notifications@localhost' }
   layout 'mailer'
   helper :instance
+
+  protected
+
+  def locale_for_account(account)
+    I18n.with_locale(account.user_locale || I18n.default_locale) do
+      yield
+    end
+  end
 end
diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb
index a944db137..12b92bf45 100644
--- a/app/mailers/notification_mailer.rb
+++ b/app/mailers/notification_mailer.rb
@@ -67,12 +67,4 @@ class NotificationMailer < ApplicationMailer
            )
     end
   end
-
-  private
-
-  def locale_for_account(account)
-    I18n.with_locale(account.user_locale || I18n.default_locale) do
-      yield
-    end
-  end
 end