Add Webhook response node (#2254)

*  Add Webhook-Response-Node

*  Replace callback function with promise

*  Add support for Bull and binary-data

*  Add string response option

*  Remove some comments

*  Make more generically possible & fix issue multi call in
queue mode

*  Fix startup and eslint issues

*  Improvements to webhook response node and functionality

*  Replace data with more generic type

*  Make statusMessage optional

*  Change parameter order

*  Move Response Code underneath options

*  Hide Response Code on Webhook node if mode responseNode got selected

*  Minor improvements

*  Add missing file and fix lint issue

*  Fix some node linting issues

*  Apply feedback

*  Minor improvements
This commit is contained in:
Jan
2021-11-05 10:45:51 -06:00
committed by GitHub
parent 70a9f0446e
commit 7b8d388d17
23 changed files with 664 additions and 65 deletions

View File

@@ -12,7 +12,7 @@ import * as PCancelable from 'p-cancelable';
import { Command, flags } from '@oclif/command';
import { UserSettings, WorkflowExecute } from 'n8n-core';
import { INodeTypes, IRun, Workflow, LoggerProxy } from 'n8n-workflow';
import { IExecuteResponsePromiseData, INodeTypes, IRun, Workflow, LoggerProxy } from 'n8n-workflow';
import { FindOneOptions } from 'typeorm';
@@ -25,11 +25,13 @@ import {
GenericHelpers,
IBullJobData,
IBullJobResponse,
IBullWebhookResponse,
IExecutionFlattedDb,
InternalHooksManager,
LoadNodesAndCredentials,
NodeTypes,
ResponseHelper,
WebhookHelpers,
WorkflowExecuteAdditionalData,
} from '../src';
@@ -172,6 +174,16 @@ export class Worker extends Command {
currentExecutionDb.workflowData,
{ retryOf: currentExecutionDb.retryOf as string },
);
additionalData.hooks.hookFunctions.sendResponse = [
async (response: IExecuteResponsePromiseData): Promise<void> => {
await job.progress({
executionId: job.data.executionId as string,
response: WebhookHelpers.encodeWebhookResponse(response),
} as IBullWebhookResponse);
},
];
additionalData.executionId = jobData.executionId;
let workflowExecute: WorkflowExecute;