From 561cf889abc776d8553f9c692a16c47b5d1a5a03 Mon Sep 17 00:00:00 2001 From: Bryan Varela Date: Tue, 16 Jun 2026 08:34:18 -0400 Subject: [PATCH] fix(daily-webhook): use BookingRepository instead of direct prisma call (#29541) --- apps/web/lib/daily-webhook/getBooking.ts | 36 +++---------------- .../repositories/BookingRepository.ts | 33 +++++++++++++++++ 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/apps/web/lib/daily-webhook/getBooking.ts b/apps/web/lib/daily-webhook/getBooking.ts index 5fcc997ab1..cd9000e9be 100644 --- a/apps/web/lib/daily-webhook/getBooking.ts +++ b/apps/web/lib/daily-webhook/getBooking.ts @@ -1,42 +1,14 @@ +import { BookingRepository } from "@calcom/features/bookings/repositories/BookingRepository"; import { HttpError } from "@calcom/lib/http-error"; import logger from "@calcom/lib/logger"; import { safeStringify } from "@calcom/lib/safeStringify"; -import prisma, { bookingMinimalSelect } from "@calcom/prisma"; +import prisma from "@calcom/prisma"; const log = logger.getSubLogger({ prefix: ["daily-video-webhook-handler"] }); -// TODO: use BookingRepository export const getBooking = async (bookingId: number) => { - const booking = await prisma.booking.findUniqueOrThrow({ - where: { - id: bookingId, - }, - select: { - ...bookingMinimalSelect, - uid: true, - location: true, - isRecorded: true, - eventTypeId: true, - eventType: { - select: { - teamId: true, - parentId: true, - canSendCalVideoTranscriptionEmails: true, - customReplyToEmail: true, - }, - }, - user: { - select: { - id: true, - timeZone: true, - email: true, - name: true, - locale: true, - destinationCalendar: true, - }, - }, - }, - }); + const bookingRepository = new BookingRepository(prisma); + const booking = await bookingRepository.findByIdWithUserAndEventType(bookingId); if (!booking) { log.error( diff --git a/packages/features/bookings/repositories/BookingRepository.ts b/packages/features/bookings/repositories/BookingRepository.ts index 96b20fdf37..76fb7bb9de 100644 --- a/packages/features/bookings/repositories/BookingRepository.ts +++ b/packages/features/bookings/repositories/BookingRepository.ts @@ -2137,4 +2137,37 @@ export class BookingRepository implements IBookingRepository { }, }); } + + async findByIdWithUserAndEventType(bookingId: number) { + return await this.prismaClient.booking.findUnique({ + where: { + id: bookingId, + }, + select: { + ...bookingMinimalSelect, + uid: true, + location: true, + isRecorded: true, + eventTypeId: true, + eventType: { + select: { + teamId: true, + parentId: true, + canSendCalVideoTranscriptionEmails: true, + customReplyToEmail: true, + }, + }, + user: { + select: { + id: true, + timeZone: true, + email: true, + name: true, + locale: true, + destinationCalendar: true, + }, + }, + }, + }); + } }