diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index aa21714..5a76373 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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? diff --git a/app/models/mailing_recipient.rb b/app/models/mailing_recipient.rb index 6839073..ebd8e4a 100644 --- a/app/models/mailing_recipient.rb +++ b/app/models/mailing_recipient.rb @@ -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 diff --git a/app/views/mailings/show.html.erb b/app/views/mailings/show.html.erb index 4922fde..f8314ba 100644 --- a/app/views/mailings/show.html.erb +++ b/app/views/mailings/show.html.erb @@ -179,9 +179,7 @@ <% if recipient.skip_reason.present? && !recipient.pending? %>