Sha256: 6cf79c77af7035f1b8bd6e533f01c0a95fd938b586b91925eb0050bd02d8b06e
Contents?: true
Size: 1.33 KB
Versions: 3
Compression:
Stored size: 1.33 KB
Contents
class Mailboxer::Message < Mailboxer::Notification attr_accessible :attachment if Mailboxer.protected_attributes? self.table_name = :mailboxer_notifications belongs_to :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, Mailboxer::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 receiver_receipts = recipients.map do |r| receipts.build(receiver: r, mailbox_type: 'inbox', is_read: false) end #Sender receipt sender_receipt = receipts.build(receiver: sender, mailbox_type: 'sentbox', is_read: true) if valid? save! Mailboxer::MailDispatcher.new(self, receiver_receipts).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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mailboxer-0.15.1 | app/models/mailboxer/message.rb |
mailboxer-0.15.0 | app/models/mailboxer/message.rb |
mailboxer-0.14.0 | app/models/mailboxer/message.rb |