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

              
                                                       
                                                    
 
                             


                                                                
                                                  

 
          
                                                                                 



                                 
                                                                         

       
require "mail"

class ActionMailroom::InboundEmail < ActiveRecord::Base
  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


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

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