aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailbox/app/jobs/action_mailbox/incineration_job.rb
blob: b12ff6f88ed06d3bf1c722e81aec07a1a8bf7ad1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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