about summary refs log tree commit diff
path: root/app/mailers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-20 00:33:02 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-20 19:39:58 +0100
commitda2ef4d676ff71e6ab3edf8d1a7cee8bf6b6d353 (patch)
treef73fa34a3323a70d5dcba360f781bce5325e3ed1 /app/mailers
parent3838e6836d47797a4e8ca20afa70eebefb68da26 (diff)
Adding unified streamable notifications
Diffstat (limited to 'app/mailers')
-rw-r--r--app/mailers/notification_mailer.rb36
1 files changed, 14 insertions, 22 deletions
diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb
index cf5ad3f92..7b2cac7f3 100644
--- a/app/mailers/notification_mailer.rb
+++ b/app/mailers/notification_mailer.rb
@@ -3,46 +3,38 @@
 class NotificationMailer < ApplicationMailer
   helper StreamEntriesHelper
 
-  def mention(mentioned_account, status)
-    @me     = mentioned_account
-    @status = status
-
-    return unless @me.user.settings(:notification_emails).mention
+  def mention(recipient, notification)
+    @me     = recipient
+    @status = notification.target_status
 
     I18n.with_locale(@me.user.locale || I18n.default_locale) do
       mail to: @me.user.email, subject: I18n.t('notification_mailer.mention.subject', name: @status.account.acct)
     end
   end
 
-  def follow(followed_account, follower)
-    @me      = followed_account
-    @account = follower
-
-    return unless @me.user.settings(:notification_emails).follow
+  def follow(recipient, notification)
+    @me      = recipient
+    @account = notification.from_account
 
     I18n.with_locale(@me.user.locale || I18n.default_locale) do
       mail to: @me.user.email, subject: I18n.t('notification_mailer.follow.subject', name: @account.acct)
     end
   end
 
-  def favourite(target_status, from_account)
-    @me      = target_status.account
-    @account = from_account
-    @status  = target_status
-
-    return unless @me.user.settings(:notification_emails).favourite
+  def favourite(recipient, notification)
+    @me      = recipient
+    @account = notification.from_account
+    @status  = notification.target_status
 
     I18n.with_locale(@me.user.locale || I18n.default_locale) do
       mail to: @me.user.email, subject: I18n.t('notification_mailer.favourite.subject', name: @account.acct)
     end
   end
 
-  def reblog(target_status, from_account)
-    @me      = target_status.account
-    @account = from_account
-    @status  = target_status
-
-    return unless @me.user.settings(:notification_emails).reblog
+  def reblog(recipient, notification)
+    @me      = recipient
+    @account = notification.from_account
+    @status  = notification.target_status
 
     I18n.with_locale(@me.user.locale || I18n.default_locale) do
       mail to: @me.user.email, subject: I18n.t('notification_mailer.reblog.subject', name: @account.acct)