refactor(core): Delete some duplicate code between ActiveWebhooks and ActiveWorkflowRunner (no-changelog) (#6951)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-08-17 17:18:14 +02:00
committed by GitHub
parent 9b27878d8f
commit 41c3cc89ca
3 changed files with 50 additions and 42 deletions

View File

@@ -972,12 +972,52 @@ export class Workflow {
return this.__getStartNode(Object.keys(this.nodes));
}
/**
* Executes the Webhooks method of the node
*
* @param {WebhookSetupMethodNames} method The name of the method to execute
*/
async runWebhookMethod(
async createWebhookIfNotExists(
webhookData: IWebhookData,
nodeExecuteFunctions: INodeExecuteFunctions,
mode: WorkflowExecuteMode,
activation: WorkflowActivateMode,
isTest?: boolean,
): Promise<void> {
const webhookExists = await this.runWebhookMethod(
'checkExists',
webhookData,
nodeExecuteFunctions,
mode,
activation,
isTest,
);
if (!webhookExists) {
// If webhook does not exist yet create it
await this.runWebhookMethod(
'create',
webhookData,
nodeExecuteFunctions,
mode,
activation,
isTest,
);
}
}
async deleteWebhook(
webhookData: IWebhookData,
nodeExecuteFunctions: INodeExecuteFunctions,
mode: WorkflowExecuteMode,
activation: WorkflowActivateMode,
isTest?: boolean,
) {
await this.runWebhookMethod(
'delete',
webhookData,
nodeExecuteFunctions,
mode,
activation,
isTest,
);
}
private async runWebhookMethod(
method: WebhookSetupMethodNames,
webhookData: IWebhookData,
nodeExecuteFunctions: INodeExecuteFunctions,