aboutsummaryrefslogblamecommitdiffstats
path: root/app/models/action_mailroom/inbound_email.rb
blob: 755d7be138d37f4e3ea939e13af2423295a1312a (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                                       
                                                    
 



                                                                


                                                





                                                                                   
                                                                         

       
class ActionMailroom::InboundEmail < ActiveRecord::Base
  self.table_name = "action_mailroom_inbound_emails"

  has_one_attached :raw_message

  enum status: %i[ pending processing delivered failed bounced ]

  after_create_commit :deliver_to_mailroom_later


  def mail
    @mail ||= Mail.new(Mail::Utilities.binary_unsafe_to_crlf(raw_message.download))
  end

  private
    def deliver_to_mailroom_later
      ActionMailroom::DeliverInboundEmailToMailroomJob.perform_later self
    end
end