Skip to content

Scheduling infrastructure for absolutely everyone.

fix: added missing prisma imports (#11867)

Omar López208d040f6fdc
diff --git a/apps/api/pages/api/event-types/_post.ts b/apps/api/pages/api/event-types/_post.ts
index f81af6171a7..79a537c4207 100644
--- a/apps/api/pages/api/event-types/_post.ts
+++ b/apps/api/pages/api/event-types/_post.ts
@@ -284,8 +284,8 @@ async function postHandler(req: NextApiRequest) {
await checkPermissions(req);
if (parsedBody.parentId) {
- await checkParentEventOwnership(parsedBody.parentId, userId);
- await checkUserMembership(parsedBody.parentId, parsedBody.userId);
+ await checkParentEventOwnership(req);
+ await checkUserMembership(req);
}
if (isAdmin && parsedBody.userId) {
diff --git a/apps/api/pages/api/event-types/_utils/checkParentEventOwnership.ts b/apps/api/pages/api/event-types/_utils/checkParentEventOwnership.ts
index 15ada700970..2e91d789b77 100644
--- a/apps/api/pages/api/event-types/_utils/checkParentEventOwnership.ts
+++ b/apps/api/pages/api/event-types/_utils/checkParentEventOwnership.ts
@@ -1,17 +1,21 @@
+import type { NextApiRequest } from "next";
+
import { HttpError } from "@calcom/lib/http-error";
/**
* Checks if a user, identified by the provided userId, has ownership (or admin rights) over
* the team associated with the event type identified by the parentId.
*
- * @param parentId - The ID of the parent event type.
- * @param userId - The ID of the user.
+ * @param req - The current request
*
* @throws {HttpError} If the parent event type is not found,
* if the parent event type doesn't belong to any team,
* or if the user doesn't have ownership or admin rights to the associated team.
*/
-export default async function checkParentEventOwnership(parentId: number, userId: number) {
+export default async function checkParentEventOwnership(req: NextApiRequest) {
+ const { userId, prisma, body } = req;
+ /** These are already parsed upstream, we can assume they're good here. */
+ const parentId = Number(body.parentId);
const parentEventType = await prisma.eventType.findUnique({
where: {
id: parentId,
diff --git a/apps/api/pages/api/event-types/_utils/checkUserMembership.ts b/apps/api/pages/api/event-types/_utils/checkUserMembership.ts
index ad449b42b3b..d76fcb89adb 100644
--- a/apps/api/pages/api/event-types/_utils/checkUserMembership.ts
+++ b/apps/api/pages/api/event-types/_utils/checkUserMembership.ts
@@ -1,17 +1,22 @@
+import type { NextApiRequest } from "next";
+
import { HttpError } from "@calcom/lib/http-error";
/**
* Checks if a user, identified by the provided userId, is a member of the team associated
* with the event type identified by the parentId.
*
- * @param parentId - The ID of the event type.
- * @param userId - The ID of the user.
+ * @param req - The current request
*
* @throws {HttpError} If the event type is not found,
* if the event type doesn't belong to any team,
* or if the user isn't a member of the associated team.
*/
-export default async function checkUserMembership(parentId: number, userId?: number) {
+export default async function checkUserMembership(req: NextApiRequest) {
+ const { prisma, body } = req;
+ /** These are already parsed upstream, we can assume they're good here. */
+ const parentId = Number(body.parentId);
+ const userId = Number(body.userId);
const parentEventType = await prisma.eventType.findUnique({
where: {
id: parentId,