From 45fd472f767e1622337c5c33e7b809497d64d7df Mon Sep 17 00:00:00 2001 From: Adam Cooke Date: Sat, 29 Apr 2017 11:56:25 +0100 Subject: [PATCH] configurable maximum delivery attempts closes #59 --- app/jobs/unqueue_message_job.rb | 2 +- app/models/queued_message.rb | 2 -- app/views/help/outgoing.html.haml | 2 +- config/postal.defaults.yml | 1 + 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/jobs/unqueue_message_job.rb b/app/jobs/unqueue_message_job.rb index 806900f..9df308c 100644 --- a/app/jobs/unqueue_message_job.rb +++ b/app/jobs/unqueue_message_job.rb @@ -51,7 +51,7 @@ class UnqueueMessageJob < Postal::Job end # We might not be able to send this any more, check the attempts - if queued_message.attempts >= QueuedMessage::MAX_ATTEMPTS + if queued_message.attempts >= Postal.config.general.maximum_delivery_attempts details = "Maximum number of delivery attempts (#{queued_message.attempts}) has been reached." if queued_message.message.scope == 'incoming' # Send bounceds to incoming e-mails when they are hard failed diff --git a/app/models/queued_message.rb b/app/models/queued_message.rb index 84027b1..fdcfb4c 100644 --- a/app/models/queued_message.rb +++ b/app/models/queued_message.rb @@ -26,8 +26,6 @@ class QueuedMessage < ApplicationRecord - MAX_ATTEMPTS = 18 - include HasMessage belongs_to :server diff --git a/app/views/help/outgoing.html.haml b/app/views/help/outgoing.html.haml index 87fdef3..42e9b28 100644 --- a/app/views/help/outgoing.html.haml +++ b/app/views/help/outgoing.html.haml @@ -18,7 +18,7 @@ Mail servers can be enabled to send mail from any domain by the administrator. %li If a message cannot be delivered, the system will not send you a bounce message but dispatch a webhook (if you set one up). - If a message delivery fails but can be retried, the system will try #{QueuedMessage::MAX_ATTEMPTS} times to deliver it before giving up. + If a message delivery fails but can be retried, the system will try #{Postal.config.general.maximum_delivery_attempts} times to deliver it before giving up. .u-margin %h2.pageContent__subTitle Sending using SMTP %p.pageContent__text diff --git a/config/postal.defaults.yml b/config/postal.defaults.yml index d8ee756..6ba24ec 100644 --- a/config/postal.defaults.yml +++ b/config/postal.defaults.yml @@ -11,6 +11,7 @@ web: general: use_ip_pools: false exception_url: + maximum_delivery_attempts: 18 web_server: bind_address: 127.0.0.1