From 1d2f75951f88baa66d9534b063ee7856865f0d00 Mon Sep 17 00:00:00 2001 From: jumagura Date: Mon, 2 Oct 2023 22:05:28 -0400 Subject: [PATCH] FIX: Use wizard_submission_id instead of new value --- lib/custom_wizard/action.rb | 1 - plugin.rb | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/custom_wizard/action.rb b/lib/custom_wizard/action.rb index ad261e9a..ac0799f3 100644 --- a/lib/custom_wizard/action.rb +++ b/lib/custom_wizard/action.rb @@ -63,7 +63,6 @@ class CustomWizard::Action def create_topic params = basic_topic_params.merge(public_topic_params) - params[:from_wizard] = true callbacks_for(:before_create_topic).each do |acb| params = acb.call(params, @wizard, @action, @submission) diff --git a/plugin.rb b/plugin.rb index 4e674b1d..62e4d225 100644 --- a/plugin.rb +++ b/plugin.rb @@ -239,10 +239,14 @@ after_initialize do on(:before_create_topic) do |topic_params, user| next if topic_params[:archetype] == 'message' - if topic_params[:category]&.custom_fields&.[]('create_topic_wizard').present? && !topic_params[:from_wizard] + category = topic_params.category + wizard_submission_id = topic_params.custom_fields['wizard_submission_id'] + + if category&.custom_fields&.[]('create_topic_wizard').present? && wizard_submission_id.blank? raise Discourse::InvalidParameters.new( I18n.t('wizard.error_messages.wizard_replacing_composer') ) end end + end