From ff20a58c709dadd202c929d5f57b3d56de6339c7 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Sun, 20 Feb 2022 16:44:30 +0100 Subject: [PATCH] :bug: Fix bug with Webhook-Process --- packages/cli/src/Server.ts | 5 ++--- packages/cli/src/WebhookHelpers.ts | 2 ++ packages/cli/src/WebhookServer.ts | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index fa2399dd62..564a0e0dbd 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -145,6 +145,7 @@ import { TagEntity } from './databases/entities/TagEntity'; import { WorkflowEntity } from './databases/entities/WorkflowEntity'; import { NameRequest } from './WorkflowHelpers'; import { getCredentialTranslationPath, getNodeTranslationPath } from './TranslationHelpers'; +import { WEBHOOK_METHODS } from './WebhookHelpers'; require('body-parser-xml')(bodyParser); @@ -240,8 +241,6 @@ class App { this.presetCredentialsLoaded = false; this.endpointPresetCredentials = config.get('credentials.overwrite.endpoint') as string; - this.webhookMethods = ['DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT']; - const urlBaseWebhook = WebhookHelpers.getWebhookBaseUrl(); const telemetrySettings: ITelemetrySettings = { @@ -2737,7 +2736,7 @@ class App { return; } - if (!this.webhookMethods.includes(method)) { + if (!WEBHOOK_METHODS.includes(method)) { ResponseHelper.sendErrorResponse( res, new Error(`The method ${method} is not supported.`), diff --git a/packages/cli/src/WebhookHelpers.ts b/packages/cli/src/WebhookHelpers.ts index 8e5c27e2e3..7dfb7fa75c 100644 --- a/packages/cli/src/WebhookHelpers.ts +++ b/packages/cli/src/WebhookHelpers.ts @@ -56,6 +56,8 @@ import * as ActiveExecutions from './ActiveExecutions'; const activeExecutions = ActiveExecutions.getInstance(); +export const WEBHOOK_METHODS = ['DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT']; + /** * Returns all the webhooks which should be created for the give workflow * diff --git a/packages/cli/src/WebhookServer.ts b/packages/cli/src/WebhookServer.ts index 45bf8c16e1..30e424dece 100644 --- a/packages/cli/src/WebhookServer.ts +++ b/packages/cli/src/WebhookServer.ts @@ -32,6 +32,7 @@ import { } from '.'; import * as config from '../config'; +import { WEBHOOK_METHODS } from './WebhookHelpers'; // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-call require('body-parser-xml')(bodyParser); @@ -70,7 +71,7 @@ export function registerProductionWebhooks() { return; } - if (!this.webhookMethods.includes(method)) { + if (!WEBHOOK_METHODS.includes(method)) { ResponseHelper.sendErrorResponse(res, new Error(`The method ${method} is not supported.`)); return; } @@ -120,7 +121,7 @@ export function registerProductionWebhooks() { // if (method === 'OPTIONS') { // } - if (!this.webhookMethods.includes(method)) { + if (!WEBHOOK_METHODS.includes(method)) { ResponseHelper.sendErrorResponse(res, new Error(`The method ${method} is not supported.`)); return; }