diff options
author | George Claghorn <george@basecamp.com> | 2018-10-06 22:23:19 -0400 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-10-06 22:23:48 -0400 |
commit | 1fddb9475fa10f46efd1afd3bb4359645ec495a4 (patch) | |
tree | 9429593e0c54ae79d843d6f739aa8d8f89946e24 | |
parent | a5e023ac204251192f9cb722c0d98695cb3b8400 (diff) | |
download | rails-1fddb9475fa10f46efd1afd3bb4359645ec495a4.tar.gz rails-1fddb9475fa10f46efd1afd3bb4359645ec495a4.tar.bz2 rails-1fddb9475fa10f46efd1afd3bb4359645ec495a4.zip |
Make incineration horizon configurable
-rw-r--r-- | app/jobs/action_mailbox/inbound_email/incineration_job.rb | 2 | ||||
-rw-r--r-- | app/models/action_mailbox/inbound_email/incineratable.rb | 3 | ||||
-rw-r--r-- | app/models/action_mailbox/inbound_email/incineratable/incineration.rb | 2 | ||||
-rw-r--r-- | lib/action_mailbox.rb | 1 | ||||
-rw-r--r-- | lib/action_mailbox/engine.rb | 2 |
5 files changed, 5 insertions, 5 deletions
diff --git a/app/jobs/action_mailbox/inbound_email/incineration_job.rb b/app/jobs/action_mailbox/inbound_email/incineration_job.rb index a2911efef1..d9422a3fa8 100644 --- a/app/jobs/action_mailbox/inbound_email/incineration_job.rb +++ b/app/jobs/action_mailbox/inbound_email/incineration_job.rb @@ -2,7 +2,7 @@ class ActionMailbox::InboundEmail::IncinerationJob < ApplicationJob queue_as :action_mailbox_incineration def self.schedule(inbound_email) - set(wait: ActionMailbox::InboundEmail::Incineratable::INCINERATABLE_AFTER).perform_later(inbound_email) + set(wait: ActionMailbox.incinerate_after).perform_later(inbound_email) end def perform(inbound_email) diff --git a/app/models/action_mailbox/inbound_email/incineratable.rb b/app/models/action_mailbox/inbound_email/incineratable.rb index 8a82b87a99..364231a443 100644 --- a/app/models/action_mailbox/inbound_email/incineratable.rb +++ b/app/models/action_mailbox/inbound_email/incineratable.rb @@ -1,9 +1,6 @@ module ActionMailbox::InboundEmail::Incineratable extend ActiveSupport::Concern - # TODO: Extract into framework configuration - INCINERATABLE_AFTER = 30.days - included do before_update :remember_to_incinerate_later after_update_commit :incinerate_later, if: :incinerating_later? diff --git a/app/models/action_mailbox/inbound_email/incineratable/incineration.rb b/app/models/action_mailbox/inbound_email/incineratable/incineration.rb index 5dd9be5a3d..ab9311edfb 100644 --- a/app/models/action_mailbox/inbound_email/incineratable/incineration.rb +++ b/app/models/action_mailbox/inbound_email/incineratable/incineration.rb @@ -9,7 +9,7 @@ class ActionMailbox::InboundEmail::Incineratable::Incineration private def due? - @inbound_email.updated_at < ActionMailbox::InboundEmail::Incineratable::INCINERATABLE_AFTER.ago.end_of_day + @inbound_email.updated_at < ActionMailbox.incinerate_after.ago.end_of_day end def processed? diff --git a/lib/action_mailbox.rb b/lib/action_mailbox.rb index ed890c488b..01cc38ec4a 100644 --- a/lib/action_mailbox.rb +++ b/lib/action_mailbox.rb @@ -9,4 +9,5 @@ module ActionMailbox autoload :Routing mattr_accessor :logger + mattr_accessor :incinerate_after, default: 30.days end diff --git a/lib/action_mailbox/engine.rb b/lib/action_mailbox/engine.rb index 4e800c54de..b4758aacb5 100644 --- a/lib/action_mailbox/engine.rb +++ b/lib/action_mailbox/engine.rb @@ -6,10 +6,12 @@ module ActionMailbox config.eager_load_namespaces << ActionMailbox config.action_mailbox = ActiveSupport::OrderedOptions.new + config.action_mailbox.incinerate_after = 30.days initializer "action_mailbox.config" do config.after_initialize do |app| ActionMailbox.logger = app.config.action_mailbox.logger || Rails.logger + ActionMailbox.incinerate_after = app.config.action_mailbox.incinerate_after || 30.days end end end |