Aggiunge pulsante per fermare un invio email in corso.
Permette di annullare i destinatari ancora in coda mantenendo le email già inviate. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -47,10 +47,13 @@ class MailingRecipient < ApplicationRecord
|
||||
def deliver!
|
||||
with_lock do
|
||||
return if status.in?(%w[sent skipped])
|
||||
return abort_delivery!("invio annullato") unless mailing.sending?
|
||||
|
||||
update!(status: "queued")
|
||||
end
|
||||
|
||||
return unless mailing.sending?
|
||||
|
||||
html = rendered_html
|
||||
subject_line = rendered_subject_line
|
||||
CampaignMailer.outreach(self, html: html, subject: subject_line).deliver_now
|
||||
@@ -63,6 +66,10 @@ class MailingRecipient < ApplicationRecord
|
||||
|
||||
private
|
||||
|
||||
def abort_delivery!(reason)
|
||||
update!(status: "skipped", skip_reason: reason)
|
||||
end
|
||||
|
||||
def record_success!(subject_line)
|
||||
transaction do
|
||||
update!(status: "sent", sent_at: Time.current, rendered_subject: subject_line, error_message: nil)
|
||||
|
||||
Reference in New Issue
Block a user