@@ -2,6 +2,7 @@ import { enrichUsersWithDelegationCredentials } from "@calcom/app-store/delegati
22import dayjs from "@calcom/dayjs" ;
33import { ensureAvailableUsers } from "@calcom/features/bookings/lib/handleNewBooking/ensureAvailableUsers" ;
44import type { IsFixedAwareUser } from "@calcom/features/bookings/lib/handleNewBooking/types" ;
5+ import { getBookingAccessService } from "@calcom/features/di/containers/BookingAccessService" ;
56import { withSelectedCalendars } from "@calcom/features/users/repositories/UserRepository" ;
67import { ErrorCode } from "@calcom/lib/errorCodes" ;
78import logger from "@calcom/lib/logger" ;
@@ -10,6 +11,8 @@ import { userSelect } from "@calcom/prisma";
1011import { credentialForCalendarServiceSelect } from "@calcom/prisma/selects/credential" ;
1112import type { TrpcSessionUser } from "@calcom/trpc/server/types" ;
1213
14+ import { TRPCError } from "@trpc/server" ;
15+
1316import type { TGetRoundRobinHostsToReassignInputSchema } from "./getRoundRobinHostsToReasign.schema" ;
1417
1518type GetRoundRobinHostsToReassignOptions = {
@@ -111,6 +114,16 @@ export const getRoundRobinHostsToReassign = async ({ ctx, input }: GetRoundRobin
111114 prefix : [ "gettingRoundRobinHostsToReassign" , `${ bookingId } ` ] ,
112115 } ) ;
113116
117+ const bookingAccessService = getBookingAccessService ( ) ;
118+ const isAllowed = await bookingAccessService . doesUserIdHaveAccessToBooking ( {
119+ userId : user . id ,
120+ bookingId,
121+ } ) ;
122+
123+ if ( ! isAllowed ) {
124+ throw new TRPCError ( { code : "FORBIDDEN" , message : "You do not have permission" } ) ;
125+ }
126+
114127 const booking = await prisma . booking . findUniqueOrThrow ( {
115128 where : { id : bookingId } ,
116129 select : {
0 commit comments