مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-12-01 05:43:04 +00:00
http 429 responses should suppress bounce messages to reduce email volume in rate limiting situations
هذا الالتزام موجود في:
@@ -54,7 +54,7 @@ class UnqueueMessageJob < Postal::Job
|
|||||||
if queued_message.attempts >= Postal.config.general.maximum_delivery_attempts
|
if queued_message.attempts >= Postal.config.general.maximum_delivery_attempts
|
||||||
details = "Maximum number of delivery attempts (#{queued_message.attempts}) has been reached."
|
details = "Maximum number of delivery attempts (#{queued_message.attempts}) has been reached."
|
||||||
if queued_message.message.scope == 'incoming'
|
if queued_message.message.scope == 'incoming'
|
||||||
# Send bounceds to incoming e-mails when they are hard failed
|
# Send bounces to incoming e-mails when they are hard failed
|
||||||
if bounce_id = queued_message.send_bounce
|
if bounce_id = queued_message.send_bounce
|
||||||
details += " Bounce sent to sender (see message <msg:#{bounce_id}>)"
|
details += " Bounce sent to sender (see message <msg:#{bounce_id}>)"
|
||||||
end
|
end
|
||||||
@@ -240,7 +240,10 @@ class UnqueueMessageJob < Postal::Job
|
|||||||
|
|
||||||
# Log the result
|
# Log the result
|
||||||
log_details = result.details
|
log_details = result.details
|
||||||
if result.type =='HardFail' && queued_message.message.send_bounces?
|
if result.type =='HardFail' && result.suppress_bounce
|
||||||
|
# The delivery hard failed, but requested that no bounce be sent
|
||||||
|
log "#{log_prefix} Suppressing bounce message after hard fail"
|
||||||
|
elsif result.type =='HardFail' && queued_message.message.send_bounces?
|
||||||
# If the message is a hard fail, send a bounce message for this message.
|
# If the message is a hard fail, send a bounce message for this message.
|
||||||
log "#{log_prefix} Sending a bounce because message hard failed"
|
log "#{log_prefix} Sending a bounce because message hard failed"
|
||||||
if bounce_id = queued_message.send_bounce
|
if bounce_id = queued_message.send_bounce
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ module Postal
|
|||||||
result.type = 'SoftFail'
|
result.type = 'SoftFail'
|
||||||
result.retry = true
|
result.retry = true
|
||||||
result.connect_error = true
|
result.connect_error = true
|
||||||
|
elsif response[:code] == 429
|
||||||
|
# Rate limit exceeded, treat as a hard fail and don't send bounces
|
||||||
|
result.type = 'HardFail'
|
||||||
|
result.suppress_bounce = true
|
||||||
else
|
else
|
||||||
# This is permanent. Any other error isn't cool with us.
|
# This is permanent. Any other error isn't cool with us.
|
||||||
result.type = 'HardFail'
|
result.type = 'HardFail'
|
||||||
|
|||||||
@@ -8,5 +8,6 @@ module Postal
|
|||||||
attr_accessor :connect_error
|
attr_accessor :connect_error
|
||||||
attr_accessor :log_id
|
attr_accessor :log_id
|
||||||
attr_accessor :time
|
attr_accessor :time
|
||||||
|
attr_accessor :suppress_bounce
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم