Skip to content

Scheduling infrastructure for absolutely everyone.

fix(daily-webhook): use BookingRepository instead of direct prisma call (#29541)

Bryan Varela561cf889abc7
diff --git a/apps/web/lib/daily-webhook/getBooking.ts b/apps/web/lib/daily-webhook/getBooking.ts
index 5fcc997ab10..cd9000e9be6 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 96b20fdf373..76fb7bb9def 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,
+ },
+ },
+ },
+ });
+ }
}