Non tratta l'EOF SMTP come invio riuscito e toglie quei falsi errori dalla lista.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -195,6 +195,15 @@ module ApplicationHelper
|
||||
end
|
||||
end
|
||||
|
||||
def mailing_recipient_delivery_note(recipient)
|
||||
if recipient.status == "failed" && recipient.error_message.present?
|
||||
content_tag :div, recipient.error_message, class: "mt-1 text-xs text-rose-700 dark:text-rose-300"
|
||||
elsif recipient.queued? && recipient.error_message.to_s.match?(/Da ritentare/)
|
||||
content_tag :div, "Non risulta inviata. Verrà ritentata in coda.",
|
||||
class: "mt-1 text-xs text-amber-800 dark:text-amber-200"
|
||||
end
|
||||
end
|
||||
|
||||
def ab_variant_badge(variant)
|
||||
return if variant.blank?
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ class MailingRecipient < ApplicationRecord
|
||||
Mailings::SmtpGate.deliver do
|
||||
CampaignMailer.outreach(self, html: html, subject: subject_line).deliver_now
|
||||
end
|
||||
# Solo dopo deliver_now senza eccezioni: un EOF/SMTP error non è mai un invio riuscito.
|
||||
record_success!(subject_line)
|
||||
:sent
|
||||
rescue *Mailings::SmtpGate::RETRYABLE => e
|
||||
|
||||
@@ -179,9 +179,7 @@
|
||||
<% if recipient.skip_reason.present? && !recipient.pending? %>
|
||||
<div class="mt-1 text-xs text-zinc-500"><%= recipient.skip_reason %></div>
|
||||
<% end %>
|
||||
<% if recipient.error_message.present? %>
|
||||
<div class="mt-1 text-xs text-rose-700"><%= recipient.error_message %></div>
|
||||
<% end %>
|
||||
<%= mailing_recipient_delivery_note(recipient) %>
|
||||
<% if recipient.sent_at.present? %>
|
||||
<div class="mt-1 text-xs text-zinc-500">
|
||||
Inviata <%= format_dt(recipient.sent_at) %>
|
||||
@@ -238,9 +236,7 @@
|
||||
<% if recipient.skip_reason.present? && !recipient.pending? %>
|
||||
<div class="text-xs text-zinc-500"><%= recipient.skip_reason %></div>
|
||||
<% end %>
|
||||
<% if recipient.error_message.present? %>
|
||||
<div class="text-xs text-rose-700"><%= recipient.error_message %></div>
|
||||
<% end %>
|
||||
<%= mailing_recipient_delivery_note(recipient) %>
|
||||
<% if recipient.sent_at.present? %>
|
||||
<div class="text-xs text-zinc-500">Inviata <%= format_dt(recipient.sent_at) %></div>
|
||||
<% end %>
|
||||
|
||||
@@ -29,4 +29,19 @@ class ApplicationHelperTest < ActionView::TestCase
|
||||
assert_includes html, "title=\"Società affiliata FIPAV con un testo molto lungo da accorciare\""
|
||||
assert_includes html, "…"
|
||||
end
|
||||
|
||||
test "queued SMTP retries are not shown as delivery failures" do
|
||||
recipient = MailingRecipient.new(status: "queued", error_message: "Da ritentare (1/8): end of file reached")
|
||||
html = mailing_recipient_delivery_note(recipient)
|
||||
|
||||
assert_includes html, "Non risulta inviata"
|
||||
assert_not_includes html, "end of file reached"
|
||||
end
|
||||
|
||||
test "failed recipients still show the SMTP error" do
|
||||
recipient = MailingRecipient.new(status: "failed", error_message: "end of file reached")
|
||||
html = mailing_recipient_delivery_note(recipient)
|
||||
|
||||
assert_includes html, "end of file reached"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user