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:
@@ -1,6 +1,6 @@
|
||||
class MailingsController < ApplicationController
|
||||
before_action :require_current_project!
|
||||
before_action :set_mailing, only: %i[show edit update destroy queue test_send test_preview refresh_recipients update_recipients preview]
|
||||
before_action :set_mailing, only: %i[show edit update destroy queue cancel test_send test_preview refresh_recipients update_recipients preview]
|
||||
before_action :load_form_collections, only: %i[new create edit update]
|
||||
|
||||
def index
|
||||
@@ -139,6 +139,20 @@ class MailingsController < ApplicationController
|
||||
redirect_to @mailing, alert: e.message
|
||||
end
|
||||
|
||||
def cancel
|
||||
unless @mailing.sending?
|
||||
redirect_to @mailing, alert: "Solo un invio in corso può essere fermato."
|
||||
return
|
||||
end
|
||||
|
||||
pending = @mailing.pending_count + @mailing.queued_count
|
||||
@mailing.cancel_send!
|
||||
redirect_to dashboard_mailings_path,
|
||||
notice: "Invio fermato. #{@mailing.sent_count} già inviate, #{pending} annullate in coda."
|
||||
rescue StandardError => e
|
||||
redirect_to @mailing, alert: e.message
|
||||
end
|
||||
|
||||
def test_send
|
||||
assign_test_preview
|
||||
to = @test_to.to_s.strip
|
||||
|
||||
Reference in New Issue
Block a user