Scheduling infrastructure for absolutely everyone.
Adds team event type check
Syed Ali Shahbazcd03f5a821e4
diff --git a/pages/api/hooks/[id].ts b/pages/api/hooks/[id].tsindex 32a81e7b12a..3a14efa5922 100644--- a/pages/api/hooks/[id].ts+++ b/pages/api/hooks/[id].ts@@ -95,6 +95,27 @@ export async function WebhookById(return;}}+ if (safeBody.data.eventTypeId) {+ const team = await ctx.prisma.team.findFirst({+ where: {+ eventTypes: {+ some: {+ id: safeBody.data.eventTypeId,+ },+ },+ },+ include: {+ members: true,+ },+ });++ // Team should be available and the user should be a member of the team+ if (!team?.members.some((membership) => membership.userId === userId)) {+ throw new TRPCError({+ code: "UNAUTHORIZED",+ });+ }+ }await prisma.webhook.update({ where: { id: safeQuery.data.id }, data: safeBody.data }).then((data) => schemaWebhookReadPublic.parse(data))