Class: Notifier

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
app/mailers/notifier.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.admin(string, recipients, opts = {}, subject = nil) ⇒ Object


6
7
8
9
10
11
12
13
# File 'app/mailers/notifier.rb', line 6

def self.admin(string, recipients, opts = {}, subject=nil)
  mails = []
  recipients.each do |rec|
    mail = single_admin(string, rec, opts.dup, subject)
    mails << mail
  end
  mails
end

Instance Method Details

#also_commented(recipient_id, sender_id, comment_id) ⇒ Object


78
79
80
# File 'app/mailers/notifier.rb', line 78

def also_commented(recipient_id, sender_id, comment_id)
  send_notification(:also_commented, recipient_id, sender_id, comment_id)
end

#comment_on_post(recipient_id, sender_id, comment_id) ⇒ Object


74
75
76
# File 'app/mailers/notifier.rb', line 74

def comment_on_post(recipient_id, sender_id, comment_id)
  send_notification(:comment_on_post, recipient_id, sender_id, comment_id)
end

#confirm_email(recipient_id) ⇒ Object


86
87
88
# File 'app/mailers/notifier.rb', line 86

def confirm_email(recipient_id)
  send_notification(:confirm_email, recipient_id)
end

#invite(email, message, inviter, invitation_code, locale) ⇒ Object


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/mailers/notifier.rb', line 40

def invite(email, message, inviter, invitation_code, locale)
  @inviter = inviter
  @message = message
  @locale = locale
  @invitation_code = invitation_code

  mail_opts = {:to => email, :from => AppConfig.mail.sender_address,
               :subject => I18n.t('notifier.invited_you', :name => @inviter.name),
               :host => AppConfig.pod_uri.host}

  I18n.with_locale(locale) do
    mail(mail_opts) do |format|
      format.text { render :layout => nil }
      format.html { render :layout => nil }
    end
  end
end

#liked(recipient_id, sender_id, like_id) ⇒ Object


62
63
64
# File 'app/mailers/notifier.rb', line 62

def liked(recipient_id, sender_id, like_id)
  send_notification(:liked, recipient_id, sender_id, like_id)
end

#mentioned(recipient_id, sender_id, target_id) ⇒ Object


70
71
72
# File 'app/mailers/notifier.rb', line 70

def mentioned(recipient_id, sender_id, target_id)
  send_notification(:mentioned, recipient_id, sender_id, target_id)
end

#private_message(recipient_id, sender_id, message_id) ⇒ Object


82
83
84
# File 'app/mailers/notifier.rb', line 82

def private_message(recipient_id, sender_id, message_id)
  send_notification(:private_message, recipient_id, sender_id, message_id)
end

#reshared(recipient_id, sender_id, reshare_id) ⇒ Object


66
67
68
# File 'app/mailers/notifier.rb', line 66

def reshared(recipient_id, sender_id, reshare_id)
  send_notification(:reshared, recipient_id, sender_id, reshare_id)
end

#single_admin(string, recipient, opts = {}, subject = nil) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/mailers/notifier.rb', line 15

def single_admin(string, recipient, opts={}, subject=nil)
  @receiver = recipient
  @string = string.html_safe

  if attach = opts.delete(:attachments)
    attach.each{ |f|
      attachments[f[:name]] = f[:file]
    }
  end

  unless subject
    subject = I18n.t('notifier.single_admin.subject')
  end

  default_opts = {:to => @receiver.email,
       :from => AppConfig.mail.sender_address,
       :subject => subject, :host => AppConfig.pod_uri.host}
  default_opts.merge!(opts)

  mail(default_opts) do |format|
    format.text
    format.html
  end
end

#started_sharing(recipient_id, sender_id) ⇒ Object


58
59
60
# File 'app/mailers/notifier.rb', line 58

def started_sharing(recipient_id, sender_id)
  send_notification(:started_sharing, recipient_id, sender_id)
end