chore: refactor code

This commit is contained in:
Catalin Pit
2024-02-27 15:22:02 +02:00
parent af30443f5a
commit f0a511e238
5 changed files with 37 additions and 18 deletions

View File

@ -10,12 +10,13 @@ export const unsubscribeHandler = async (req: NextApiRequest, res: NextApiRespon
const { webhookId } = req.body;
const user = await validateApiToken({ authorization });
const result = await validateApiToken({ authorization });
const deletedWebhook = await prisma.webhook.delete({
where: {
id: webhookId,
userId: user.id,
userId: result.userId ? result.userId : result.user.id,
teamId: result.userId ? undefined : result.teamId,
},
});