mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(core): Improve test-webhooks (no-changelog) (#8069)
Remove duplication, improve readability, and expand tests for `TestWebhooks.ts` - in anticipation for storing test webhooks in Redis. --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -60,7 +60,7 @@ import { WorkflowRunner } from '@/WorkflowRunner';
|
||||
import { ExternalHooks } from '@/ExternalHooks';
|
||||
import { whereClause } from './UserManagement/UserManagementHelper';
|
||||
import { WorkflowService } from './workflows/workflow.service';
|
||||
import { webhookNotFoundErrorMessage } from './utils';
|
||||
import { WebhookNotFoundError } from './errors/response-errors/webhook-not-found.error';
|
||||
import { In } from 'typeorm';
|
||||
import { WebhookService } from './services/webhook.service';
|
||||
import { Logger } from './Logger';
|
||||
@@ -71,9 +71,6 @@ import { ActivationErrorsService } from '@/ActivationErrors.service';
|
||||
import type { Scope } from '@n8n/permissions';
|
||||
import { NotFoundError } from './errors/response-errors/not-found.error';
|
||||
|
||||
const WEBHOOK_PROD_UNREGISTERED_HINT =
|
||||
"The workflow must be active for a production URL to run successfully. You can activate the workflow using the toggle in the top-right of the editor. Note that unlike test URL calls, production URL calls aren't shown on the canvas (only in the executions list)";
|
||||
|
||||
@Service()
|
||||
export class ActiveWorkflowRunner implements IWebhookManager {
|
||||
activeWorkflows = new ActiveWorkflows();
|
||||
@@ -256,10 +253,7 @@ export class ActiveWorkflowRunner implements IWebhookManager {
|
||||
|
||||
const webhook = await this.webhookService.findWebhook(httpMethod, path);
|
||||
if (webhook === null) {
|
||||
throw new NotFoundError(
|
||||
webhookNotFoundErrorMessage(path, httpMethod),
|
||||
WEBHOOK_PROD_UNREGISTERED_HINT,
|
||||
);
|
||||
throw new WebhookNotFoundError({ path, httpMethod }, { hint: 'production' });
|
||||
}
|
||||
|
||||
return webhook;
|
||||
@@ -383,7 +377,6 @@ export class ActiveWorkflowRunner implements IWebhookManager {
|
||||
NodeExecuteFunctions,
|
||||
mode,
|
||||
activation,
|
||||
false,
|
||||
);
|
||||
} catch (error) {
|
||||
if (activation === 'init' && error.name === 'QueryFailedError') {
|
||||
@@ -455,7 +448,7 @@ export class ActiveWorkflowRunner implements IWebhookManager {
|
||||
const webhooks = WebhookHelpers.getWorkflowWebhooks(workflow, additionalData, undefined, true);
|
||||
|
||||
for (const webhookData of webhooks) {
|
||||
await workflow.deleteWebhook(webhookData, NodeExecuteFunctions, mode, 'update', false);
|
||||
await workflow.deleteWebhook(webhookData, NodeExecuteFunctions, mode, 'update');
|
||||
}
|
||||
|
||||
await Container.get(WorkflowService).saveStaticData(workflow);
|
||||
|
||||
Reference in New Issue
Block a user