aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/action_mailroom/inbound_email.rb13
-rw-r--r--app/models/action_mailroom/inbound_email/routable.rb12
2 files changed, 14 insertions, 11 deletions
diff --git a/app/models/action_mailroom/inbound_email.rb b/app/models/action_mailroom/inbound_email.rb
index d44007c2f1..c439988e91 100644
--- a/app/models/action_mailroom/inbound_email.rb
+++ b/app/models/action_mailroom/inbound_email.rb
@@ -1,23 +1,14 @@
require "mail"
class ActionMailroom::InboundEmail < ActiveRecord::Base
- include Incineratable
-
self.table_name = "action_mailroom_inbound_emails"
- has_one_attached :raw_email
+ include Incineratable, Routable
+ 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
diff --git a/app/models/action_mailroom/inbound_email/routable.rb b/app/models/action_mailroom/inbound_email/routable.rb
new file mode 100644
index 0000000000..b888c592f5
--- /dev/null
+++ b/app/models/action_mailroom/inbound_email/routable.rb
@@ -0,0 +1,12 @@
+module ActionMailroom::InboundEmail::Routable
+ extend ActiveSupport::Concern
+
+ included do
+ after_create_commit :route_later, if: ->(r) { r.pending? }
+ end
+
+ private
+ def route_later
+ ActionMailroom::RoutingJob.perform_later self
+ end
+end