Method: Mailboxer::Notification#deliver

Defined in:
app/models/mailboxer/notification.rb

#deliver(should_clean = true, send_mail = true) ⇒ Object

Delivers a Notification. USE NOT RECOMENDED. Use Mailboxer::Models::Message.notify and Notification.notify_all instead.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'app/models/mailboxer/notification.rb', line 81

def deliver(should_clean = true, send_mail = true)
  clean if should_clean
  temp_receipts = recipients.map do |r|
    receipts.build(receiver: r, mailbox_type: nil, is_read: false)
  end

  if valid?
    Mailboxer::MailDispatcher.new(self, temp_receipts).call if send_mail
    save!

    self.recipients = nil
  end

  return temp_receipts if temp_receipts.size > 1
  temp_receipts.first
end