Sha256: 2b47bba9b2eec6891348b25f4d15d7b5a7f803257d54c51d3c41629084a57c72

Contents?: true

Size: 1.25 KB

Versions: 9

Compression:

Stored size: 1.25 KB

Contents

class MessageMailer < ActionMailer::Base
  default :from => Mailboxer.default_from
  #Sends and email for indicating a new message or a reply to a receiver. 
  #It calls new_message_email if notifing a new message and reply_message_email
  #when indicating a reply to an already created conversation.
  def send_email(message,receiver)    
    if message.conversation.messages.size > 0
      reply_message_email(message,receiver)
    else
      new_message_email(message,receiver)
    end
  end
  
  include ActionView::Helpers::SanitizeHelper

  #Sends an email for indicating a new message for the receiver
  def new_message_email(message,receiver)
    @message = message
    @receiver = receiver
    mail(:to => receiver.email, :subject => "You have a new message: " + strip_tags(message.subject)) do |format|
      format.html {render __method__}
      format.text {render __method__}
    end
  end

  #Sends and email for indicating a reply in an already created conversation
  def reply_message_email(message,receiver)
    @message = message
    @receiver = receiver
    mail(:to => receiver.email, :subject => "You have a new reply: " + strip_tags(message.subject)) do |format|
      format.html {render __method__}
      format.text {render __method__}
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mailboxer-0.2.3 app/mailers/message_mailer.rb
mailboxer-0.2.2 app/mailers/message_mailer.rb
mailboxer-0.2.1 app/mailers/message_mailer.rb
mailboxer-0.2.0 app/mailers/message_mailer.rb
mailboxer-0.1.4 app/mailers/message_mailer.rb
mailboxer-0.1.3 app/mailers/message_mailer.rb
mailboxer-0.1.2 app/mailers/message_mailer.rb
mailboxer-0.1.1 app/mailers/message_mailer.rb
mailboxer-0.1.0 app/mailers/message_mailer.rb