From 130f69caf54f5e76c3d5c0299735f4ce57af9cf0 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 8 Dec 2020 11:47:33 +0000 Subject: [PATCH] Fixing automations to use recurseMustache from utilities. --- packages/server/src/automations/thread.js | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/packages/server/src/automations/thread.js b/packages/server/src/automations/thread.js index 6c02875a03..771de65463 100644 --- a/packages/server/src/automations/thread.js +++ b/packages/server/src/automations/thread.js @@ -3,6 +3,7 @@ const actions = require("./actions") const logic = require("./logic") const automationUtils = require("./automationUtils") const AutomationEmitter = require("../events/AutomationEmitter") +const { recurseMustache } = require("../utilities/mustache") handlebars.registerHelper("object", value => { return new handlebars.SafeString(JSON.stringify(value)) @@ -10,22 +11,6 @@ handlebars.registerHelper("object", value => { const FILTER_STEP_ID = logic.BUILTIN_DEFINITIONS.FILTER.stepId -function recurseMustache(inputs, context) { - for (let key of Object.keys(inputs)) { - let val = inputs[key] - if (typeof val === "string") { - val = automationUtils.cleanMustache(inputs[key]) - const template = handlebars.compile(val) - inputs[key] = template(context) - } - // this covers objects and arrays - else if (typeof val === "object") { - inputs[key] = recurseMustache(inputs[key], context) - } - } - return inputs -} - /** * The automation orchestrator is a class responsible for executing automations. * It handles the context of the automation and makes sure each step gets the correct