Feature: Routing Forms Webhook for Form Responses (#3444)

Co-authored-by: Omar López <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2022-07-20 18:30:57 +00:00
1 parent b47c75304e
commit 5b7cd476a7
15 files changed
+164 -22

No files matched your search

+5 -1
View File
@@ -71,11 +71,13 @@ export const webhookRouter = createProtectedRouter()
input: z
.object({
eventTypeId: z.number().optional(),
appId: z.string().optional(),
})
.optional(),
async resolve({ ctx, input }) {
const where: Prisma.WebhookWhereInput = {
AND: [{ appId: null /* Don't mixup zapier webhooks with normal ones */ }],
/* Don't mixup zapier webhooks with normal ones */
AND: [{ appId: !input?.appId ? null : input.appId }],
};
if (Array.isArray(where.AND)) {
if (input?.eventTypeId) {
@@ -84,6 +86,7 @@ export const webhookRouter = createProtectedRouter()
where.AND?.push({ userId: ctx.user.id });
}
}
return await ctx.prisma.webhook.findMany({
where,
});
@@ -108,6 +111,7 @@ export const webhookRouter = createProtectedRouter()
},
});
}
return await ctx.prisma.webhook.create({
data: {
id: v4(),