Sha256: 55db5f82ba10dff65bf33d67f1ecc753110bb87b35275d7d184960737b231498
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
class Mailboxer::Message < Mailboxer::Notification attr_accessible :attachment if Mailboxer.protected_attributes? self.table_name = :mailboxer_notifications belongs_to :conversation, :class_name => "Mailboxer::Conversation", :validate => true, :autosave => true validates_presence_of :sender class_attribute :on_deliver_callback protected :on_deliver_callback scope :conversation, lambda { |conversation| where(:conversation_id => conversation.id) } mount_uploader :attachment, AttachmentUploader class << self #Sets the on deliver callback method. def on_deliver(callback_method) self.on_deliver_callback = callback_method end end #Delivers a Message. USE NOT RECOMENDED. #Use Mailboxer::Models::Message.send_message instead. def deliver(reply = false, should_clean = true) self.clean if should_clean #Receiver receipts temp_receipts = recipients.map { |r| build_receipt(r, 'inbox') } #Sender receipt sender_receipt = build_receipt(sender, 'sentbox', true) temp_receipts << sender_receipt if temp_receipts.all?(&:valid?) temp_receipts.each(&:save!) #Save receipts Mailboxer::MailDispatcher.new(self, recipients).call conversation.touch if reply self.recipients = nil on_deliver_callback.call(self) if on_deliver_callback end sender_receipt end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mailboxer-0.12.0.rc1 | app/models/mailboxer/message.rb |