From 9eef1665f536eae568970eb07764cd8b4e5f7f99 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Thu, 9 Nov 2023 08:36:46 +0100 Subject: [PATCH] :ambulance: (zapier) Fix execute webhook endpoint too strict on block type check --- .../typebots/[typebotId]/blocks/[blockId]/executeWebhook.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/viewer/src/pages/api/typebots/[typebotId]/blocks/[blockId]/executeWebhook.ts b/apps/viewer/src/pages/api/typebots/[typebotId]/blocks/[blockId]/executeWebhook.ts index c2febf849..44ae3eaa7 100644 --- a/apps/viewer/src/pages/api/typebots/[typebotId]/blocks/[blockId]/executeWebhook.ts +++ b/apps/viewer/src/pages/api/typebots/[typebotId]/blocks/[blockId]/executeWebhook.ts @@ -10,7 +10,7 @@ import { } from '@typebot.io/schemas' import { NextApiRequest, NextApiResponse } from 'next' import got, { Method, Headers, HTTPError } from 'got' -import { byId, isEmpty, omit } from '@typebot.io/lib' +import { byId, isEmpty, isWebhookBlock, omit } from '@typebot.io/lib' import { parseAnswers } from '@typebot.io/lib/results' import { initMiddleware, methodNotAllowed, notFound } from '@typebot.io/lib/api' import { stringify } from 'qs' @@ -27,7 +27,6 @@ import { defaultWebhookAttributes, } from '@typebot.io/schemas/features/blocks/integrations/webhook/constants' import { getBlockById } from '@typebot.io/lib/getBlockById' -import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integrations/constants' const cors = initMiddleware(Cors()) @@ -52,7 +51,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { const block = typebot.groups .flatMap((g) => g.blocks) .find(byId(blockId)) - if (block?.type !== IntegrationBlockType.WEBHOOK) + if (!block || !isWebhookBlock(block)) return notFound(res, 'Webhook block not found') const webhookId = 'webhookId' in block ? block.webhookId : undefined const webhook =