2018-12-14 05:06:12 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-12-26 16:18:42 -05:00
|
|
|
module ActionMailbox
|
2019-01-15 10:55:42 -05:00
|
|
|
# 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.
|
2018-12-26 16:18:42 -05:00
|
|
|
#
|
2019-01-15 10:55:42 -05:00
|
|
|
# Since this incineration is set for the future, it'll automatically ignore any <tt>InboundEmail</tt>s
|
2018-12-26 16:18:42 -05:00
|
|
|
# that have already been deleted and discard itself if so.
|
|
|
|
class IncinerationJob < ActiveJob::Base
|
|
|
|
queue_as { ActionMailbox.queues[:incineration] }
|
2018-09-28 15:19:43 -04:00
|
|
|
|
2018-12-26 16:18:42 -05:00
|
|
|
discard_on ActiveRecord::RecordNotFound
|
2018-11-09 13:45:51 -05:00
|
|
|
|
2018-12-26 16:18:42 -05:00
|
|
|
def self.schedule(inbound_email)
|
|
|
|
set(wait: ActionMailbox.incinerate_after).perform_later(inbound_email)
|
|
|
|
end
|
2018-09-28 15:19:43 -04:00
|
|
|
|
2018-12-26 16:18:42 -05:00
|
|
|
def perform(inbound_email)
|
|
|
|
inbound_email.incinerate
|
|
|
|
end
|
2018-09-28 15:19:43 -04:00
|
|
|
end
|
|
|
|
end
|