mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
⚡ Prepare webhooks for multitenancy
This commit is contained in:
@@ -495,7 +495,7 @@ export interface IWebhookData {
|
||||
node: string;
|
||||
path: string;
|
||||
webhookDescription: IWebhookDescription;
|
||||
workflow: Workflow;
|
||||
workflowId: string;
|
||||
workflowExecuteAdditionalData: IWorkflowExecuteAdditionalData;
|
||||
}
|
||||
|
||||
|
||||
@@ -771,7 +771,7 @@ export function getNodeWebhooks(workflow: Workflow, node: INode, additionalData:
|
||||
node: node.name,
|
||||
path,
|
||||
webhookDescription,
|
||||
workflow,
|
||||
workflowId: workflow.id,
|
||||
workflowExecuteAdditionalData: additionalData,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user