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

Fix/event type validations
This commit is contained in:
Agusti Fernandez Pardo
2022-05-28 01:52:06 +02:00
committed by GitHub
3 changed files with 22 additions and 16 deletions
+9 -7
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
+12 -9
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(),
})
);
+1
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) {