Skip to content

chore: Integrate confirmation booking audit#10

Open
tomerqodo wants to merge 2 commits into
copilot_full_base_chore_integrate_confirmation_booking_audit_pr10from
copilot_full_head_chore_integrate_confirmation_booking_audit_pr10
Open

chore: Integrate confirmation booking audit#10
tomerqodo wants to merge 2 commits into
copilot_full_base_chore_integrate_confirmation_booking_audit_pr10from
copilot_full_head_chore_integrate_confirmation_booking_audit_pr10

Conversation

@tomerqodo

Copy link
Copy Markdown

Benchmark PR from agentic-review-benchmarks#10

Copilot AI review requested due to automatic review settings January 25, 2026 21:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request integrates comprehensive audit tracking for booking confirmation and rejection events across all entry points in the Cal.com application. The PR adds support for tracking when bookings are accepted or rejected through the webapp, API v2, magic links, and payment webhooks.

Changes:

  • Adds MAGIC_LINK as a new audit source in the database schema
  • Integrates audit event firing for booking confirmations and rejections across all entry points
  • Updates payment webhook handlers to pass actor and action source information
  • Adds comprehensive test coverage for the new audit functionality
  • Implements bulk audit event support for recurring bookings

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/trpc/server/routers/viewer/bookings/confirm.handler.ts Main confirmation handler - integrates rejection audit events with a critical bug in oldStatus capture for recurring bookings
packages/features/bookings/lib/handleConfirmation.ts Confirmation handler - integrates acceptance audit events with a critical bug in oldStatus for non-recurring bookings
packages/trpc/server/routers/viewer/bookings/_router.tsx TRPC router - adds actor and actionSource to confirm handler inputs
packages/prisma/schema.prisma Schema update - adds MAGIC_LINK to BookingAuditSource enum
packages/prisma/migrations/20260107093019_add_magic_link_source/migration.sql Migration file for MAGIC_LINK enum value
packages/features/booking-audit/lib/types/actionSource.ts Type updates - adds ValidActionSource schema without UNKNOWN
packages/features/booking-audit/lib/actions/RejectedAuditActionService.ts Updates rejection action schema to use BookingStatusChangeSchema
packages/features/bookings/lib/onBookingEvents/BookingEventHandlerService.ts Adds onBulkBookingsRejected method
packages/features/booking-audit/lib/service/BookingAuditTaskerProducerService.ts Adds queueBulkRejectedAudit method
packages/features/booking-audit/lib/service/BookingAuditProducerService.interface.ts Interface update with queueBulkRejectedAudit method and formatting
packages/features/ee/payments/api/webhook.ts Stripe webhook - adds actor and actionSource to handleConfirmation calls
packages/app-store/paypal/api/webhook.ts PayPal webhook - updates handlePaymentSuccess signature
packages/app-store/hitpay/api/webhook.ts HitPay webhook - updates handlePaymentSuccess signature
packages/app-store/btcpayserver/api/webhook.ts BTCPay webhook - updates handlePaymentSuccess signature
packages/app-store/alby/api/webhook.ts Alby webhook - updates handlePaymentSuccess signature
packages/app-store/_utils/payments/handlePaymentSuccess.ts Payment handler - changes signature to object parameter and adds audit support
packages/app-store/_utils/getAppActor.ts New utility for creating app actors with credential fallback
apps/web/app/api/verify-booking-token/route.ts Verification token handler - adds audit parameters
apps/web/app/api/link/route.ts Link handler - adds audit parameters
apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts API v2 service - adds audit parameters to confirm/reject calls
packages/platform/libraries/bookings.ts Exports makeUserActor for platform usage
packages/features/booking-audit/lib/service/__tests__/accepted-action.integration-test.ts Comprehensive integration tests for accepted action auditing
packages/app-store/_utils/payments/handlePaymentSuccess.test.ts Updates tests for new function signature
apps/web/test/lib/confirm.handler.test.ts Comprehensive tests for both acceptance and rejection audit events
apps/web/app/api/verify-booking-token/__tests__/route.test.ts Updates tests with audit parameters
apps/web/app/api/link/__tests__/route.test.ts Updates tests with audit parameters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +432 to +444
const updatedRecurringBookings = await prisma.booking.findMany({
where: {
uid: {
in: unconfirmedRecurringBookings.map((booking) => booking.uid),
},
},
select: {
uid: true,
status: true,
},
});

rejectedBookings = updatedRecurringBookings.map((recurringBooking) => ({

Copilot AI Jan 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The oldStatus is incorrectly set after the database update. At this point, updatedRecurringBookings already have status REJECTED (from the previous updateMany call on lines 420-430), so oldStatus will incorrectly be REJECTED instead of PENDING. The oldStatus should be captured from unconfirmedRecurringBookings before the update, similar to how it's done in handleConfirmation.ts (lines 263-266).

Suggested change
const updatedRecurringBookings = await prisma.booking.findMany({
where: {
uid: {
in: unconfirmedRecurringBookings.map((booking) => booking.uid),
},
},
select: {
uid: true,
status: true,
},
});
rejectedBookings = updatedRecurringBookings.map((recurringBooking) => ({
rejectedBookings = unconfirmedRecurringBookings.map((recurringBooking) => ({

Copilot uses AI. Check for mistakes.
updatedBookings.push(updatedBooking);
acceptedBookings = [
{
oldStatus: BookingStatus.ACCEPTED,

Copilot AI Jan 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The oldStatus is hardcoded to BookingStatus.ACCEPTED, but this is incorrect. For a non-recurring booking acceptance, the oldStatus should be the booking's status before the update (likely PENDING). It should be set to booking.status, similar to how it's done correctly in the recurring case (line 264) and in the rejection path in confirm.handler.ts (line 471).

Suggested change
oldStatus: BookingStatus.ACCEPTED,
oldStatus: booking.status,

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants