Merge pull request #101 from calcom/fix-event-types-id

fix: event types id endpoints
pull/9078/head
Agusti Fernandez Pardo 2022-05-27 21:45:17 +02:00 committed by GitHub
commit eee5fd0090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 12 deletions

View File

@ -93,16 +93,16 @@ export const schemaEventTypeReadPublic = EventType.pick({
metadata: true,
}).merge(
z.object({
// { dtstart?: Date | undefined; interval?: number | undefined; count?: number | undefined; freq?: Frequency | undefined; until?: Date | undefined; tzid?: string | undefined; } | undefined'
// recurringEvent: jsonSchema.nullable(),
recurringEvent: z.object({
recurringEvent: z
.object({
dtstart: z.date().optional(),
interval: z.number().int().optional(),
count: z.number().int().optional(),
freq: z.nativeEnum(Frequency).optional(),
until: z.date().optional(),
tzid: timeZone,
}),
tzid: timeZone.optional(),
})
.optional(),
locations: z.array(
z.object({
link: z.string().optional(),

View File

@ -19,8 +19,12 @@ export async function eventTypeById(
res.status(400).json({ message: "Your query was invalid" });
return;
}
const data = await prisma.eventType.findMany({ where: { userId } });
const userEventTypes = data.map((eventType) => eventType.id);
const data = await await prisma.user.findUnique({
where: { id: userId },
rejectOnNotFound: true,
select: { eventTypes: true },
});
const userEventTypes = data.eventTypes.map((eventType) => eventType.id);
if (!userEventTypes.includes(safeQuery.data.id)) res.status(401).json({ message: "Unauthorized" });
else {
switch (method) {