1
0
Fork 0
mirror of synced 2024-06-27 18:40:42 +12:00

Fixing an issue where inputs from the builder send empty string when realistically it means no input.

This commit is contained in:
mike12345567 2020-09-18 14:34:14 +01:00
parent 0aa1c38878
commit 85dcb28375
2 changed files with 25 additions and 3 deletions

View file

@ -10,13 +10,34 @@ const triggers = require("../../workflows/triggers")
* *
*************************/
function cleanWorkflowInputs(workflow) {
if (workflow == null) {
return workflow
}
let steps = workflow.definition.steps
let trigger = workflow.definition.trigger
let allSteps = [...steps, trigger]
for (let step of allSteps) {
if (step == null) {
continue
}
for (let inputName of Object.keys(step.inputs)) {
if (!step.inputs[inputName] || step.inputs[inputName] === "") {
delete step.inputs[inputName]
}
}
}
return workflow
}
exports.create = async function(ctx) {
const db = new CouchDB(ctx.user.instanceId)
const workflow = ctx.request.body
let workflow = ctx.request.body
workflow._id = newid()
workflow.type = "workflow"
workflow = cleanWorkflowInputs(workflow)
const response = await db.post(workflow)
workflow._rev = response.rev
@ -32,8 +53,9 @@ exports.create = async function(ctx) {
exports.update = async function(ctx) {
const db = new CouchDB(ctx.user.instanceId)
const workflow = ctx.request.body
let workflow = ctx.request.body
workflow = cleanWorkflowInputs(workflow)
const response = await db.put(workflow)
workflow._rev = response.rev

View file

@ -53,7 +53,7 @@ module.exports.run = async function({ inputs }) {
to: inputs.to,
from: inputs.from,
subject: inputs.subject,
text: inputs.text ? inputs.text : "Empty",
text: inputs.contents ? inputs.contents : "Empty",
}
try {