diff options
Diffstat (limited to 'actionmailbox/app/jobs/action_mailbox/incineration_job.rb')
-rw-r--r-- | actionmailbox/app/jobs/action_mailbox/incineration_job.rb | 22 |
1 files changed, 22 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..224c9329a5 --- /dev/null +++ b/actionmailbox/app/jobs/action_mailbox/incineration_job.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module ActionMailbox + # 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 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 +end |