Carica oggetto e corpo dell'email appena si sceglie un template A/B.
CI / scan_ruby (push) Failing after 10m36s
CI / scan_js (push) Successful in 10m31s
CI / lint (push) Failing after 11m0s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-17 23:24:39 +02:00
co-authored by Cursor
parent c4e5f289cf
commit 4ddf534a0c
5 changed files with 150 additions and 29 deletions
+5 -6
View File
@@ -166,19 +166,18 @@ class MailingsController < ApplicationController
end
def apply_template_if_needed
copy_template(params.dig(:mailing, :mail_template_id), :subject, :body_html, params[:use_template_content])
copy_template(params.dig(:mailing, :mail_template_b_id), :subject_b, :body_html_b, params[:use_template_b_content])
copy_template_if_blank(params.dig(:mailing, :mail_template_id), :subject, :body_html)
copy_template_if_blank(params.dig(:mailing, :mail_template_b_id), :subject_b, :body_html_b)
end
def copy_template(template_id, subject_attr, body_attr, flag)
def copy_template_if_blank(template_id, subject_attr, body_attr)
return if template_id.blank?
return unless ActiveModel::Type::Boolean.new.cast(flag)
template = MailTemplate.for_project(current_project).find_by(id: template_id)
return unless template
@mailing.public_send("#{subject_attr}=", template.subject)
@mailing.public_send("#{body_attr}=", template.body_html)
@mailing.public_send("#{subject_attr}=", template.subject) if @mailing.public_send(subject_attr).blank?
@mailing.public_send("#{body_attr}=", template.body_html) if @mailing.public_send(body_attr).blank?
end
def rebuild_recipients_if_needed