mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix
This commit is contained in:
parent
0fdb79a270
commit
4f9dd1016d
|
@ -57,6 +57,30 @@ export class WaitingForms extends WaitingWebhooks {
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private findCompletionPage(execution: IExecutionResponse, lastNodeExecuted: string) {
|
||||||
|
const workflow = this.getWorkflow(execution);
|
||||||
|
const parentNodes = workflow.getParentNodes(lastNodeExecuted);
|
||||||
|
const lastNode = workflow.nodes[lastNodeExecuted];
|
||||||
|
|
||||||
|
if (
|
||||||
|
!lastNode.disabled &&
|
||||||
|
lastNode.type === FORM_NODE_TYPE &&
|
||||||
|
lastNode.parameters.operation === 'completion'
|
||||||
|
) {
|
||||||
|
return lastNodeExecuted;
|
||||||
|
} else {
|
||||||
|
return parentNodes.reverse().find((nodeName) => {
|
||||||
|
const node = workflow.nodes[nodeName];
|
||||||
|
return (
|
||||||
|
!node.disabled &&
|
||||||
|
node.type === FORM_NODE_TYPE &&
|
||||||
|
node.parameters.operation === 'completion' &&
|
||||||
|
execution.data.resultData.runData[nodeName]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async executeWebhook(
|
async executeWebhook(
|
||||||
req: WaitingWebhookRequest,
|
req: WaitingWebhookRequest,
|
||||||
res: express.Response,
|
res: express.Response,
|
||||||
|
@ -89,34 +113,12 @@ export class WaitingForms extends WaitingWebhooks {
|
||||||
throw new ConflictError(`The execution "${executionId}" is running already.`);
|
throw new ConflictError(`The execution "${executionId}" is running already.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let completionPage;
|
let lastNodeExecuted = execution.data.resultData.lastNodeExecuted as string;
|
||||||
|
|
||||||
if (execution.finished) {
|
if (execution.finished) {
|
||||||
const workflow = this.getWorkflow(execution);
|
// find the completion page to render
|
||||||
|
// if there is no completion page, render the default page
|
||||||
const parentNodes = workflow.getParentNodes(
|
const completionPage = this.findCompletionPage(execution, lastNodeExecuted);
|
||||||
execution.data.resultData.lastNodeExecuted as string,
|
|
||||||
);
|
|
||||||
|
|
||||||
const lastNodeExecuted = execution.data.resultData.lastNodeExecuted as string;
|
|
||||||
const lastNode = workflow.nodes[lastNodeExecuted];
|
|
||||||
|
|
||||||
if (
|
|
||||||
!lastNode.disabled &&
|
|
||||||
lastNode.type === FORM_NODE_TYPE &&
|
|
||||||
lastNode.parameters.operation === 'completion'
|
|
||||||
) {
|
|
||||||
completionPage = lastNodeExecuted;
|
|
||||||
} else {
|
|
||||||
completionPage = Object.keys(workflow.nodes).find((nodeName) => {
|
|
||||||
const node = workflow.nodes[nodeName];
|
|
||||||
return (
|
|
||||||
parentNodes.includes(nodeName) &&
|
|
||||||
!node.disabled &&
|
|
||||||
node.type === FORM_NODE_TYPE &&
|
|
||||||
node.parameters.operation === 'completion'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!completionPage) {
|
if (!completionPage) {
|
||||||
res.render('form-trigger-completion', {
|
res.render('form-trigger-completion', {
|
||||||
|
@ -128,16 +130,16 @@ export class WaitingForms extends WaitingWebhooks {
|
||||||
return {
|
return {
|
||||||
noWebhookResponse: true,
|
noWebhookResponse: true,
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
lastNodeExecuted = completionPage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetNode = completionPage || (execution.data.resultData.lastNodeExecuted as string);
|
|
||||||
|
|
||||||
return await this.getWebhookExecutionData({
|
return await this.getWebhookExecutionData({
|
||||||
execution,
|
execution,
|
||||||
req,
|
req,
|
||||||
res,
|
res,
|
||||||
lastNodeExecuted: targetNode,
|
lastNodeExecuted,
|
||||||
executionId,
|
executionId,
|
||||||
suffix,
|
suffix,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue