about summary refs log tree commit diff
path: root/app/mailers/notification_mailer.rb
blob: cf5ad3f929d6ff0fca10e626a255777672667e76 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true

class NotificationMailer < ApplicationMailer
  helper StreamEntriesHelper

  def mention(mentioned_account, status)
    @me     = mentioned_account
    @status = status

    return unless @me.user.settings(:notification_emails).mention

    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

    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

    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

    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)
    end
  end
end