about summary refs log tree commit diff
path: root/app/mailers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-19 19:20:07 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-19 19:20:07 +0100
commit2b116131d78460e5cbb8eacc30aaaf04106ea0fa (patch)
tree62ff3751b4f94b36335d5bd7d45374e024cd1d19 /app/mailers
parente2b846f630cae00096a42dffeff759d0ef8e1c3e (diff)
Adding e-mail notifications about mentions, follows, favourites and reblogs. Fixing another mention recording bug
Diffstat (limited to 'app/mailers')
-rw-r--r--app/mailers/application_mailer.rb4
-rw-r--r--app/mailers/notification_mailer.rb34
2 files changed, 38 insertions, 0 deletions
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
new file mode 100644
index 000000000..1a3196acd
--- /dev/null
+++ b/app/mailers/application_mailer.rb
@@ -0,0 +1,4 @@
+class ApplicationMailer < ActionMailer::Base
+  default from: (ENV['SMTP_FROM_ADDRESS'] || 'notifications@localhost')
+  layout 'mailer'
+end
diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb
new file mode 100644
index 000000000..1414c2295
--- /dev/null
+++ b/app/mailers/notification_mailer.rb
@@ -0,0 +1,34 @@
+class NotificationMailer < ApplicationMailer
+  helper StreamEntriesHelper
+  helper AtomBuilderHelper
+
+  def mention(mentioned_account, status)
+    @me     = mentioned_account
+    @status = status
+
+    mail to: @me.user.email, subject: "You were mentioned by #{@status.account.acct}"
+  end
+
+  def follow(followed_account, follower)
+    @me      = followed_account
+    @account = follower
+
+    mail to: @me.user.email, subject: "#{@account.acct} is now following you"
+  end
+
+  def favourite(target_status, from_account)
+    @me      = target_status.account
+    @account = from_account
+    @status  = target_status
+
+    mail to: @me.user.email, subject: "#{@account.acct} favourited your status"
+  end
+
+  def reblog(target_status, from_account)
+    @me      = target_status.account
+    @account = from_account
+    @status  = target_status
+
+    mail to: @me.user.email, subject: "#{@account.acct} reblogged your status"
+  end
+end