From f30ac466723a7411c90cf64a03ada48bc5816ae7 Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Wed, 14 Dec 2022 20:50:33 +0100 Subject: [PATCH] feat($): add flow.setRemoteWebhookId --- packages/backend/src/helpers/global-variable.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/backend/src/helpers/global-variable.ts b/packages/backend/src/helpers/global-variable.ts index 6834b081..ed4dd968 100644 --- a/packages/backend/src/helpers/global-variable.ts +++ b/packages/backend/src/helpers/global-variable.ts @@ -37,6 +37,7 @@ const globalVariable = async ( testRun = false, } = options; + const isTrigger = step?.isTrigger; const lastInternalId = testRun ? undefined : await flow?.lastInternalId(); const nextStep = await step?.getNextStep(); @@ -123,6 +124,18 @@ const globalVariable = async ( $.webhookUrl = webhookUrl; } + if (isTrigger && (await step.getTriggerCommand()).type === 'webhook') { + $.flow.setRemoteWebhookId = async (remoteWebhookId) => { + await flow.$query().patchAndFetch({ + remoteWebhookId, + }); + + $.flow.remoteWebhookId = remoteWebhookId; + }; + + $.flow.remoteWebhookId = flow.remoteWebhookId; + } + const lastInternalIds = testRun || (flow && step.isAction) ? [] : await flow?.lastInternalIds(2000);