mirror of
https://github.com/n8n-io/n8n.git
synced 2024-09-20 23:07:32 -07:00
⚡ Make sure that Test-Webhooks use the current data not from DB
This commit is contained in:
parent
87f2e8b91c
commit
1391bf39c6
|
@ -1,11 +1,6 @@
|
||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
import {
|
|
||||||
In as findIn,
|
|
||||||
FindManyOptions,
|
|
||||||
} from 'typeorm';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Db,
|
|
||||||
IResponseCallbackData,
|
IResponseCallbackData,
|
||||||
IWorkflowDb,
|
IWorkflowDb,
|
||||||
NodeTypes,
|
NodeTypes,
|
||||||
|
@ -67,10 +62,9 @@ export class TestWebhooks {
|
||||||
throw new ResponseHelper.ResponseError('The requested webhook is not registred.', 404, 404);
|
throw new ResponseHelper.ResponseError('The requested webhook is not registred.', 404, 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
const workflowData = await Db.collections.Workflow!.findOne(webhookData.workflowId);
|
const webhookKey = this.activeWebhooks!.getWebhookKey(webhookData.httpMethod, webhookData.path);
|
||||||
if (workflowData === undefined) {
|
|
||||||
throw new ResponseHelper.ResponseError(`Could not find workflow with id "${webhookData.workflowId}"`, 404, 404);
|
const workflowData = this.testWebhookData[webhookKey].workflowData;
|
||||||
}
|
|
||||||
|
|
||||||
const nodeTypes = NodeTypes();
|
const nodeTypes = NodeTypes();
|
||||||
const workflow = new Workflow(webhookData.workflowId, workflowData.nodes, workflowData.connections, workflowData.active, nodeTypes, workflowData.staticData, workflowData.settings);
|
const workflow = new Workflow(webhookData.workflowId, workflowData.nodes, workflowData.connections, workflowData.active, nodeTypes, workflowData.staticData, workflowData.settings);
|
||||||
|
@ -82,8 +76,6 @@ export class TestWebhooks {
|
||||||
throw new ResponseHelper.ResponseError('Could not find node to process webhook.', 404, 404);
|
throw new ResponseHelper.ResponseError('Could not find node to process webhook.', 404, 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
const webhookKey = this.activeWebhooks!.getWebhookKey(webhookData.httpMethod, webhookData.path);
|
|
||||||
|
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const executionMode = 'manual';
|
const executionMode = 'manual';
|
||||||
|
@ -206,19 +198,18 @@ export class TestWebhooks {
|
||||||
if (this.activeWebhooks === null) {
|
if (this.activeWebhooks === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nodeTypes = NodeTypes();
|
const nodeTypes = NodeTypes();
|
||||||
|
|
||||||
const findQuery = {
|
let workflowData: IWorkflowDb;
|
||||||
where: {
|
let workflow: Workflow;
|
||||||
id: findIn(this.activeWebhooks.getWorkflowIds())
|
|
||||||
},
|
|
||||||
} as FindManyOptions;
|
|
||||||
|
|
||||||
const workflowsDb = await Db.collections.Workflow!.find(findQuery);
|
|
||||||
const workflows: Workflow[] = [];
|
const workflows: Workflow[] = [];
|
||||||
for (const workflowData of workflowsDb) {
|
for (const webhookKey of Object.keys(this.testWebhookData)) {
|
||||||
const workflow = new Workflow(workflowData.id.toString(), workflowData.nodes, workflowData.connections, workflowData.active, nodeTypes, workflowData.staticData, workflowData.settings);
|
console.log('webhookKey: ' + webhookKey);
|
||||||
workflows.push(workflow);
|
|
||||||
|
workflowData = this.testWebhookData[webhookKey].workflowData;
|
||||||
|
workflow = new Workflow(workflowData.id.toString(), workflowData.nodes, workflowData.connections, workflowData.active, nodeTypes, workflowData.staticData, workflowData.settings);
|
||||||
|
workflows.push();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.activeWebhooks.removeAll(workflows);
|
return this.activeWebhooks.removeAll(workflows);
|
||||||
|
|
Loading…
Reference in a new issue