fix(automations): strip execution_delay when cloning a rule with the feature off
clone duplicates the rule via dup (including execution_delay) with no param for ensure_execution_delay_allowed to inspect, so it could create new delayed rules while the feature is disabled. Drop the delay on the clone unless the account has delayed_automations enabled, matching create/update.
This commit is contained in:
@@ -49,6 +49,9 @@ class Api::V1::Accounts::AutomationRulesController < Api::V1::Accounts::BaseCont
|
||||
def clone
|
||||
automation_rule = Current.account.automation_rules.find_by(id: params[:automation_rule_id])
|
||||
new_rule = automation_rule.dup
|
||||
# dup copies execution_delay; drop it when the feature is off so clone can't create new
|
||||
# delayed rules that create/update would reject.
|
||||
new_rule.execution_delay = nil unless delayed_automations_enabled?
|
||||
new_rule.save!
|
||||
@automation_rule = new_rule
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user