Prepare webhooks for multitenancy

This commit is contained in:
Jan Oberhauser
2020-01-22 15:06:43 -08:00
parent 01a2dd13d5
commit aa1899f81d
10 changed files with 121 additions and 144 deletions

View File

@@ -495,7 +495,7 @@ export interface IWebhookData {
node: string;
path: string;
webhookDescription: IWebhookDescription;
workflow: Workflow;
workflowId: string;
workflowExecuteAdditionalData: IWorkflowExecuteAdditionalData;
}

View File

@@ -771,7 +771,7 @@ export function getNodeWebhooks(workflow: Workflow, node: INode, additionalData:
node: node.name,
path,
webhookDescription,
workflow,
workflowId: workflow.id,
workflowExecuteAdditionalData: additionalData,
});
}

View File

@@ -907,41 +907,6 @@ export class Workflow {
}
/**
* Executes the hooks of the node
*
* @param {string} hookName The name of the hook to execute
* @param {IWebhookData} webhookData
* @param {INodeExecuteFunctions} nodeExecuteFunctions
* @param {WorkflowExecuteMode} mode
* @returns {Promise<void>}
* @memberof Workflow
*/
async runNodeHooks(hookName: string, webhookData: IWebhookData, nodeExecuteFunctions: INodeExecuteFunctions, mode: WorkflowExecuteMode): Promise<void> {
const node = this.getNode(webhookData.node) as INode;
const nodeType = this.nodeTypes.getByName(node.type) as INodeType;
if (nodeType.description.hooks === undefined) {
return;
}
if (nodeType.description.hooks[hookName] === undefined) {
return;
}
if (nodeType.hooks === undefined && nodeType.description.hooks[hookName]!.length !== 0) {
// There should be hook functions but they do not exist
throw new Error('There are hooks defined to run but are not implemented.');
}
for (const hookDescription of nodeType.description.hooks[hookName]!) {
const thisArgs = nodeExecuteFunctions.getExecuteHookFunctions(this, node, webhookData.workflowExecuteAdditionalData, mode);
await nodeType.hooks![hookDescription.method].call(thisArgs);
}
}
/**
* Executes the Webhooks method of the node