mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
✨ Add support for webhook route parameters (#1343)
* 🚧 add webhookId to URL * 🚧 add webhookId to webhook entity, 🔧 refactor migrations * 🚧 🐘 postgres migration * 🚧 add mySQL migration * 🚧 refactor mongoDB * 🚧 add webhookId to IWebhookDb * 🚧 starting workflow with dynamic route works * ⚡ production dynamic webhooks complete * 🎨 fix lint issues * 🔧 dynamic path for webhook-test complete * 🎨 fix lint issues * 🎨 fix typescript issue * ⚡ add error message for dynamic webhook-test * 🔨 improve handling of leading `/` * 🚧 add webhookId to URL * 🚧 add webhookId to webhook entity, 🔧 refactor migrations * 🚧 🐘 postgres migration * 🚧 add mySQL migration * 🚧 refactor mongoDB * 🚧 add webhookId to IWebhookDb * 🚧 starting workflow with dynamic route works * ⚡ production dynamic webhooks complete * 🎨 fix lint issues * 🔧 dynamic path for webhook-test complete * 🎨 fix lint issues * 🎨 fix typescript issue * ⚡ add error message for dynamic webhook-test * 🔨 improve handling of leading `/` * ⚡ Fix issue that tab-title did not get reset on new workflow * Revert "⚡ Fix issue that tab-title did not get reset on new workflow" This reverts commit 699d0a8946e08339558c72b2714601329fbf5f2c. * 🔧 reset params before extraction * 🐘 removing unique constraint for webhookId * 🚧 handle multiple webhooks per id * 🔧 enable webhook-test for multiple WH with same id * 🐘 add migration for postgres * ⚡ add mysql migration * 🎨 fix lint issue Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
@@ -641,13 +641,13 @@ export function getNodeParameters(nodePropertiesArray: INodeProperties[], nodeVa
|
||||
}
|
||||
}
|
||||
|
||||
// Itterate over all collections
|
||||
// Iterate over all collections
|
||||
for (const itemName of Object.keys(propertyValues || {})) {
|
||||
if (nodeProperties.typeOptions !== undefined && nodeProperties.typeOptions.multipleValues === true) {
|
||||
// Multiple can be set so will be an array
|
||||
|
||||
const tempArrayValue: INodeParameters[] = [];
|
||||
// Itterate over all items as it contains multiple ones
|
||||
// Iterate over all items as it contains multiple ones
|
||||
for (const nodeValue of (propertyValues as INodeParameters)[itemName] as INodeParameters[]) {
|
||||
nodePropertyOptions = nodeProperties!.options!.find((nodePropertyOptions) => nodePropertyOptions.name === itemName) as INodePropertyCollection;
|
||||
|
||||
@@ -779,6 +779,11 @@ export function getNodeWebhooks(workflow: Workflow, node: INode, additionalData:
|
||||
continue;
|
||||
}
|
||||
|
||||
let webhookId: string | undefined;
|
||||
if ((path.startsWith(':') || path.includes('/:')) && node.webhookId) {
|
||||
webhookId = node.webhookId;
|
||||
}
|
||||
|
||||
returnData.push({
|
||||
httpMethod: httpMethod.toString() as WebhookHttpMethod,
|
||||
node: node.name,
|
||||
@@ -786,6 +791,7 @@ export function getNodeWebhooks(workflow: Workflow, node: INode, additionalData:
|
||||
webhookDescription,
|
||||
workflowId,
|
||||
workflowExecuteAdditionalData: additionalData,
|
||||
webhookId,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -883,6 +889,13 @@ export function getNodeWebhookPath(workflowId: string, node: INode, path: string
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getNodeWebhookUrl(baseUrl: string, workflowId: string, node: INode, path: string, isFullPath?: boolean): string {
|
||||
if ((path.startsWith(':') || path.includes('/:')) && node.webhookId) {
|
||||
// setting this to false to prefix the webhookId
|
||||
isFullPath = false;
|
||||
}
|
||||
if (path.startsWith('/')) {
|
||||
path = path.slice(1);
|
||||
}
|
||||
return `${baseUrl}/${getNodeWebhookPath(workflowId, node, path, isFullPath)}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user