🔀 Merge branch 'feat/webhook-node/response-mode' of https://github.com/Jhalter5Stones/n8n into Jhalter5Stones-feat/webhook-node/response-mode

This commit is contained in:
Jan Oberhauser 2022-02-19 11:32:29 +01:00
commit cb3f0a0ec6
2 changed files with 24 additions and 1 deletions

View file

@ -204,7 +204,14 @@ export async function executeWebhook(
200,
) as number;
if (!['onReceived', 'lastNode', 'responseNode'].includes(responseMode as string)) {
if (
![
'onReceived',
'lastNode',
'responseNode',
'noBodyResponse'
].includes(responseMode as string)
) {
// If the mode is not known we error. Is probably best like that instead of using
// the default that people know as early as possible (probably already testing phase)
// that something does not resolve properly.
@ -349,6 +356,17 @@ export async function executeWebhook(
didSendResponse = true;
}
// Some systems require that a webhook doesn't respond with any data
// if responseMode is set to noBodyResponse we will see this fire
if (responseMode === 'noBodyResponse' && !didSendResponse) {
// Return response without data
responseCallback(null, {
responseCode,
});
didSendResponse = true;
}
// Initialize the data of the webhook node
const nodeExecutionStack: IExecuteData[] = [];
nodeExecutionStack.push({

View file

@ -165,6 +165,11 @@ export class Webhook implements INodeType {
value: 'responseNode',
description: 'Response defined in that node',
},
{
name: 'No Body Response',
value: 'noBodyResponse',
description: 'Returns data without a body',
},
],
default: 'onReceived',
description: 'When and how to respond to the webhook.',