Merge pull request #102 from calcom/fix/event-type-validations

Fix/event type validations
pull/9078/head
Agusti Fernandez Pardo 2022-05-28 01:52:06 +02:00 committed by GitHub
commit 849c4aa240
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 16 deletions

View File

@ -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

View File

@ -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(),
})
);

View File

@ -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) {