blob: d44007c2f1cb8bb7d6c9f5387865a5947d75dfb3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
require "mail"
class ActionMailroom::InboundEmail < ActiveRecord::Base
include Incineratable
self.table_name = "action_mailroom_inbound_emails"
has_one_attached :raw_email
enum status: %i[ pending processing delivered failed bounced ]
after_create_commit :deliver_to_mailroom_later, if: ->(r) { r.pending? }
def mail
@mail ||= Mail.new(Mail::Utilities.binary_unsafe_to_crlf(raw_email.download))
end
private
def deliver_to_mailroom_later
ActionMailroom::RoutingJob.perform_later self
end
end
|