chore: [Booking Cancellation Refactor - 2] Inject repositories and use them instead of Prisma in cancellation flow#60
chore: [Booking Cancellation Refactor - 2] Inject repositories and use them instead of Prisma in cancellation flow#60
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| createdDate: true, | ||
| trialEndsAt: true, | ||
| completedOnboarding: true, | ||
| locale: true, |
There was a problem hiding this comment.
Missing locale field causes incorrect organizer translation
Medium Severity
The locale field was removed from userSelect in UserRepository.ts, but handleCancelBooking.ts still accesses organizer.locale at lines 337 and 370 to determine the organizer's translation language. Since findByIdOrThrow uses userSelect which no longer includes locale, the organizer's locale will always be undefined, causing the translation to fall back to "en" regardless of the organizer's actual language preference. This affects cancellation emails and notifications.
Additional Locations (1)
| externalCalendarId: true, | ||
| credentialId: true, | ||
| }, | ||
| gte: bookingToDelete.startTime, |
There was a problem hiding this comment.
Query filter mismatch in recurring booking cancellation
Medium Severity
The findManyIncludeWorkflowRemindersAndReferences query uses gte: bookingToDelete.startTime while the preceding updateMany uses a conditionally computed gte value (cancelSubsequentBookings ? bookingToDelete.startTime : new Date()). When allRemainingBookings is true but cancelSubsequentBookings is false, the updateMany cancels bookings from new Date() onwards, but the find query fetches bookings from bookingToDelete.startTime, potentially including bookings that weren't actually cancelled.
Benchmark PR from qodo-benchmark#664
Note
Modernizes the booking cancellation flow to use repository-based DI instead of direct Prisma and adds supporting infrastructure and tests.
handleCancelBookingand APIBookingCancelServiceto injecteduser,booking,profile,bookingReference, andattendeerepositoriesBookingRepository(updateMany,updateIncludeWorkflowRemindersAndReferences,findManyIncludeWorkflowRemindersAndReferences) and implements DTO interfaces (IBookingRepository,IBookingReferenceRepository,IProfileRepository)PrismaBookingAttendeeRepositorywithdeleteManyByBookingIdand extendsBookingReferenceRepositorywithupdateManyByBookingIdBookingReferenceRepository,BookingAttendeeRepository, andProfileRepository; updates Nest module providers inbooking-cancel.module.tsProfileRepositoryto be DI-ready and addsfindFirstByUserIdWritten by Cursor Bugbot for commit 72b8c3a. Configure here.