2
0

fix(api): 🐛 subscribeWebhook upsert

This commit is contained in:
Baptiste Arnaud
2022-03-18 14:31:11 +01:00
parent 1423c14547
commit cfbea6bbba

View File

@ -24,9 +24,10 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const { webhookId } = typebot.blocks
.find(byId(blockId))
?.steps.find(byId(stepId)) as WebhookStep
await prisma.webhook.update({
await prisma.webhook.upsert({
where: { id: webhookId },
data: { url, body: '{{state}}', method: 'POST' },
update: { url, body: '{{state}}', method: 'POST' },
create: { url, body: '{{state}}', method: 'POST', typebotId },
})
return res.send({ message: 'success' })