diff options
author | George Claghorn <george@basecamp.com> | 2018-12-24 15:16:22 -0500 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-12-25 21:32:35 -0500 |
commit | a5b2fff64ca0c1fa7be5124f40a251d991c10a85 (patch) | |
tree | 33a79841402b7151e52d9ad3949ce54f320c10aa /actionmailbox/app/jobs | |
parent | 4298df00ae6219b9b5b7c40f281d4fa4d66f4383 (diff) | |
parent | dcddff1d2d0c695318670686a27429a76f20ae03 (diff) | |
download | rails-a5b2fff64ca0c1fa7be5124f40a251d991c10a85.tar.gz rails-a5b2fff64ca0c1fa7be5124f40a251d991c10a85.tar.bz2 rails-a5b2fff64ca0c1fa7be5124f40a251d991c10a85.zip |
Import Action Mailbox
Diffstat (limited to 'actionmailbox/app/jobs')
-rw-r--r-- | actionmailbox/app/jobs/action_mailbox/incineration_job.rb | 20 | ||||
-rw-r--r-- | actionmailbox/app/jobs/action_mailbox/routing_job.rb | 11 |
2 files changed, 31 insertions, 0 deletions
diff --git a/actionmailbox/app/jobs/action_mailbox/incineration_job.rb b/actionmailbox/app/jobs/action_mailbox/incineration_job.rb new file mode 100644 index 0000000000..b12ff6f88e --- /dev/null +++ b/actionmailbox/app/jobs/action_mailbox/incineration_job.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +# You can configure when this `IncinerationJob` will be run as a time-after-processing using the +# `config.action_mailbox.incinerate_after` or `ActionMailbox.incinerate_after` setting. +# +# Since this incineration is set for the future, it'll automatically ignore any `InboundEmail`s +# that have already been deleted and discard itself if so. +class ActionMailbox::IncinerationJob < ActiveJob::Base + queue_as { ActionMailbox.queues[:incineration] } + + discard_on ActiveRecord::RecordNotFound + + def self.schedule(inbound_email) + set(wait: ActionMailbox.incinerate_after).perform_later(inbound_email) + end + + def perform(inbound_email) + inbound_email.incinerate + end +end diff --git a/actionmailbox/app/jobs/action_mailbox/routing_job.rb b/actionmailbox/app/jobs/action_mailbox/routing_job.rb new file mode 100644 index 0000000000..fc3388daff --- /dev/null +++ b/actionmailbox/app/jobs/action_mailbox/routing_job.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +# Routing a new InboundEmail is an asynchronous operation, which allows the ingress controllers to quickly +# accept new incoming emails without being burdened to hang while they're actually being processed. +class ActionMailbox::RoutingJob < ActiveJob::Base + queue_as { ActionMailbox.queues[:routing] } + + def perform(inbound_email) + inbound_email.route + end +end |