Merge pull request #102 from calcom/fix/event-type-validations
Fix/event type validationspull/9078/head
commit
849c4aa240
16
lib/types.ts
16
lib/types.ts
|
@ -142,13 +142,15 @@ interface EventTypeExtended extends Omit<EventType, "recurringEvent" | "location
|
|||
freq?: Frequency | undefined;
|
||||
until?: Date | undefined;
|
||||
tzid?: string | undefined;
|
||||
};
|
||||
locations: {
|
||||
link?: string | undefined;
|
||||
address?: string | undefined;
|
||||
hostPhoneNumber?: string | undefined;
|
||||
type: DefaultLocationType | AppStoreLocationType;
|
||||
}[];
|
||||
} | null;
|
||||
locations:
|
||||
| {
|
||||
link?: string | undefined;
|
||||
address?: string | undefined;
|
||||
hostPhoneNumber?: string | undefined;
|
||||
type: DefaultLocationType | AppStoreLocationType;
|
||||
}[]
|
||||
| null;
|
||||
}
|
||||
|
||||
// EventType
|
||||
|
|
|
@ -102,15 +102,18 @@ export const schemaEventTypeReadPublic = EventType.pick({
|
|||
until: z.date().optional(),
|
||||
tzid: timeZone.optional(),
|
||||
})
|
||||
.optional(),
|
||||
locations: z.array(
|
||||
z.object({
|
||||
link: z.string().optional(),
|
||||
address: z.string().optional(),
|
||||
hostPhoneNumber: z.string().optional(),
|
||||
type: z.nativeEnum(DefaultLocationType).or(z.nativeEnum(AppStoreLocationType)),
|
||||
})
|
||||
),
|
||||
.optional()
|
||||
.nullable(),
|
||||
locations: z
|
||||
.array(
|
||||
z.object({
|
||||
link: z.string().optional(),
|
||||
address: z.string().optional(),
|
||||
hostPhoneNumber: z.string().optional(),
|
||||
type: z.nativeEnum(DefaultLocationType).or(z.nativeEnum(AppStoreLocationType)),
|
||||
})
|
||||
)
|
||||
.nullable(),
|
||||
metadata: jsonSchema.nullable(),
|
||||
})
|
||||
);
|
||||
|
|
|
@ -25,6 +25,7 @@ export async function eventTypeById(
|
|||
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) {
|
||||
|
|
Loading…
Reference in New Issue