fix: add eventTypeId and eventTypeSlug guard (#25773)
* fix: add eventTypeId and eventTypeSlug guard * chore: update test * refactor: improvemnt * revert: --------- Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
This commit is contained in:
co-authored by
Syed Ali Shahbaz
parent
c52eff65a2
commit
2c7cb530a1
@@ -245,7 +245,9 @@ describe("POST /api/bookings", () => {
|
||||
|
||||
const { req, res } = createMocks<CustomNextApiRequest, CustomNextApiResponse>({
|
||||
method: "POST",
|
||||
body: {},
|
||||
body: {
|
||||
eventTypeId: 2,
|
||||
},
|
||||
});
|
||||
|
||||
await handler(req, res);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { getDefaultEvent } from "@calcom/features/eventtypes/lib/defaultEvents";
|
||||
import { HttpError } from "@calcom/lib/http-error";
|
||||
import { withReporting } from "@calcom/lib/sentryWrapper";
|
||||
|
||||
import { getBookingFieldsWithSystemFields } from "../getBookingFields";
|
||||
@@ -11,6 +12,10 @@ const _getEventType = async ({
|
||||
eventTypeId: number;
|
||||
eventTypeSlug?: string;
|
||||
}) => {
|
||||
if (!eventTypeId && !eventTypeSlug) {
|
||||
throw new HttpError({ statusCode: 400, message: "Either eventTypeId or eventTypeSlug must be provided" });
|
||||
}
|
||||
|
||||
// handle dynamic user
|
||||
const eventType =
|
||||
!eventTypeId && !!eventTypeSlug ? getDefaultEvent(eventTypeSlug) : await getEventTypesFromDB(eventTypeId);
|
||||
|
||||
Reference in New Issue
Block a user