chore: Integrate creation/rescheduling booking audit for Recurring/regular booking/seated bookings (#26046)

* Integrate creation/rescheduling booking audit

* fix: add missing hostUserUuid to booking audit test data

Co-Authored-By: [email protected] <[email protected]>

* fix-ci

* feat: enhance booking audit with seat reference

- Added support for seat reference in booking audit actions.
- Updated localization for booking creation to include seat information.
- Modified relevant services to pass attendee seat ID during booking creation.

* fix: update test data to match schema requirements

- Add seatReferenceUid: null to default mock audit log data
- Add seatReferenceUid: null to multiple audit logs test case
- Convert SEAT_RESCHEDULED test data to use numeric timestamps instead of ISO strings

Co-Authored-By: [email protected] <[email protected]>

* Allow nullish seatReferenceUid

* feat: enhance booking audit to support rescheduledBy information

- Updated booking audit actions to include rescheduledBy details, allowing tracking of who rescheduled a booking.
- Refactored related services to accommodate the new rescheduledBy parameter in booking events.
- Adjusted type definitions and function signatures to reflect the changes in the booking audit context.

* Avoid possible run time issue

* Fix imoport path

* fix failing test due to merge from main\

* Pass useruuid

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Hariom BalharaandDevin AI authored and GitHub committed 2026-01-13 13:16:16 +00:00
1 parent 0408ce0741
commit 75d611c2e8
36 files changed
+1198 -453

No files matched your search

@@ -349,6 +349,7 @@ export class BookingsController_2024_04_15 {
platformBookingLocation: bookingRequest.platformBookingLocation,
noEmail: bookingRequest.body.noEmail,
},
creationSource: "API_V2",
});
createdBookings.forEach(async (booking) => {
@@ -37,7 +37,6 @@ import { BadRequestException } from "@nestjs/common";
import { Request } from "express";
import { DateTime } from "luxon";
import { z } from "zod";
export const BOOKING_REASSIGN_PERMISSION_ERROR = "You do not have permission to reassign this booking";
import {
@@ -116,7 +115,7 @@ export class BookingsService_2024_08_13 {
private readonly recurringBookingService: RecurringBookingService,
private readonly instantBookingCreateService: InstantBookingCreateService,
private readonly eventTypeAccessService: EventTypeAccessService
) {}
) { }
async createBooking(request: Request, body: CreateBookingInput, authUser: AuthOptionalUser) {
let bookingTeamEventType = false;
@@ -322,8 +321,7 @@ export class BookingsService_2024_08_13 {
const allowedOptionValues = eventTypeBookingField.options.map((opt) => opt.value);
if (!this.isValidSingleOptionValue(submittedValue, allowedOptionValues)) {
throw new BadRequestException(
`Invalid option '${submittedValue}' for booking field '${
eventTypeBookingField.name
`Invalid option '${submittedValue}' for booking field '${eventTypeBookingField.name
}'. Allowed options are: ${allowedOptionValues.join(", ")}.`
);
}
@@ -337,8 +335,7 @@ export class BookingsService_2024_08_13 {
const allowedOptionValues = eventTypeBookingField.options.map((opt) => opt.value);
if (!this.areValidMultipleOptionValues(submittedValues, allowedOptionValues)) {
throw new BadRequestException(
`One or more invalid options for booking field '${
eventTypeBookingField.name
`One or more invalid options for booking field '${eventTypeBookingField.name
}'. Allowed options are: ${allowedOptionValues.join(", ")}.`
);
}
@@ -352,8 +349,7 @@ export class BookingsService_2024_08_13 {
const allowedOptionValues = eventTypeBookingField.options.map((opt) => opt.value);
if (!this.areValidMultipleOptionValues(submittedValues, allowedOptionValues)) {
throw new BadRequestException(
`One or more invalid options for booking field '${
eventTypeBookingField.name
`One or more invalid options for booking field '${eventTypeBookingField.name
}'. Allowed options are: ${allowedOptionValues.join(", ")}.`
);
}
@@ -368,8 +364,7 @@ export class BookingsService_2024_08_13 {
const allowedOptionValues = eventTypeBookingField.options.map((opt) => opt.value);
if (!this.isValidSingleOptionValue(submittedValue, allowedOptionValues)) {
throw new BadRequestException(
`Invalid option '${submittedValue}' for booking field '${
eventTypeBookingField.name
`Invalid option '${submittedValue}' for booking field '${eventTypeBookingField.name
}'. Allowed options are: ${allowedOptionValues.join(", ")}.`
);
}
@@ -465,6 +460,7 @@ export class BookingsService_2024_08_13 {
noEmail: bookingRequest.noEmail,
areCalendarEventsEnabled: bookingRequest.areCalendarEventsEnabled,
},
creationSource: "API_V2",
});
const ids = bookings.map((booking) => booking.id || 0);
return this.outputService.getOutputRecurringBookings(ids);
@@ -489,6 +485,7 @@ export class BookingsService_2024_08_13 {
platformBookingLocation: bookingRequest.platformBookingLocation,
areCalendarEventsEnabled: bookingRequest.areCalendarEventsEnabled,
},
creationSource: "API_V2",
});
return this.outputService.getOutputCreateRecurringSeatedBookings(
bookings.map((booking) => ({ uid: booking.uid || "", seatUid: booking.seatReferenceUid || "" })),
@@ -1,10 +1,30 @@
import { RegularBookingModule } from "@/lib/modules/regular-booking.module";
import { RecurringBookingService } from "@/lib/services/recurring-booking.service";
import { Module } from "@nestjs/common";
import { BookingEventHandlerService } from "@/lib/services/booking-event-handler.service";
import { Logger } from "@/lib/logger.bridge";
import { Scope } from "@nestjs/common";
import { BookingAuditProducerService } from "@/lib/services/booking-audit-producer.service";
import { HashedLinkService } from "@/lib/services/hashed-link.service";
import { TaskerService } from "@/lib/services/tasker.service";
@Module({
imports: [RegularBookingModule],
providers: [RecurringBookingService],
providers: [
RecurringBookingService,
BookingEventHandlerService,
/** Required by BookingEventHandlerService - Starts **/
HashedLinkService,
{
provide: Logger,
useFactory: () => {
return new Logger();
},
scope: Scope.TRANSIENT,
},
BookingAuditProducerService,
TaskerService,
/** Required by BookingEventHandlerService - Ends **/
],
exports: [RecurringBookingService],
})
export class RecurringBookingModule {}
export class RecurringBookingModule { }
@@ -1,13 +1,18 @@
import { RegularBookingService } from "@/lib/services/regular-booking.service";
import { BookingEventHandlerService } from "@/lib/services/booking-event-handler.service";
import { Injectable } from "@nestjs/common";
import { RecurringBookingService as BaseRecurringBookingService } from "@calcom/platform-libraries/bookings";
@Injectable()
export class RecurringBookingService extends BaseRecurringBookingService {
constructor(regularBookingService: RegularBookingService) {
constructor(
regularBookingService: RegularBookingService,
bookingEventHandler: BookingEventHandlerService
) {
super({
regularBookingService,
bookingEventHandler,
});
}
}
+1 -18
View File
@@ -58,24 +58,7 @@ async function handler(req: NextApiRequest & { userId?: number; traceContext: Tr
},
});
// const booking = await createBookingThroughFactory();
return booking;
// To be added in the follow-up PR
// async function createBookingThroughFactory() {
// console.log("Creating booking through factory");
// const regularBookingService = getRegularBookingService();
// const booking = await regularBookingService.createBooking({
// bookingData: req.body,
// bookingMeta: {
// userId: session?.user?.id || -1,
// hostname: req.headers.host || "",
// forcedSlug: req.headers["x-cal-force-slug"] as string | undefined,
// },
// });
// return booking;
// }
}
export default defaultResponder(handler, "/api/book/event");
export default defaultResponder(handler, "/api/book/event");
+2 -2
View File
@@ -1,5 +1,4 @@
import type { NextApiRequest } from "next";
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import { getRecurringBookingService } from "@calcom/features/bookings/di/RecurringBookingService.container";
import type { BookingResponse } from "@calcom/features/bookings/types";
@@ -55,6 +54,7 @@ async function handler(req: NextApiRequest & RequestMeta) {
platformBookingLocation: req.platformBookingLocation,
noEmail: req.noEmail,
},
creationSource: "WEBAPP",
});
return createdBookings;
@@ -62,4 +62,4 @@ async function handler(req: NextApiRequest & RequestMeta) {
export const handleRecurringEventBooking = handler;
export default defaultResponder(handler);
export default defaultResponder(handler);
+13 -6
View File
@@ -3321,7 +3321,7 @@
"only_if_field_is_empty": "Only if field is empty",
"booking_start_date": "Booking start date",
"booking_created_date": "Booking created date",
"booking_reassigned_to_host": "Booking reassigned to {{host}}",
"booking_reassigned_to_host": "Reassigned to {{host}}",
"no_contact_owner": "No contact owner",
"routing_forms_created": "Routing forms created",
"routing_forms_total_responses": "Total Responses",
@@ -3718,13 +3718,15 @@
"pbac_action_delete": "Delete",
"pbac_action_manage": "Manage",
"pbac_action_invite": "Invite",
"pbac_action_remove": "Remove",
"pbac_action_remove": "Remove",
"pbac_action_change_member_role": "Change member role",
"pbac_action_list_members": "List members",
"pbac_action_manage_billing": "Manage billing",
"pbac_action_read_team_bookings": "View team bookings",
"pbac_action_read_org_bookings": "View organization bookings",
"pbac_action_read_recordings": "View recordings",
"pbac_action_read_team_booking_audit_logs": "View team booking audit logs",
"pbac_action_read_org_booking_audit_logs": "View organization booking audit logs",
"pbac_action_impersonate": "Impersonate",
"pbac_action_edit_users": "Edit users",
"role_created_successfully": "Role created successfully",
@@ -3795,6 +3797,8 @@
"pbac_desc_view_team_bookings": "View team bookings",
"pbac_desc_view_organization_bookings": "View organization bookings",
"pbac_desc_view_booking_recordings": "View booking recordings",
"pbac_desc_read_team_booking_audit_logs": "View audit logs for team bookings",
"pbac_desc_read_org_booking_audit_logs": "View audit logs for organization bookings",
"pbac_desc_update_bookings": "Update bookings",
"pbac_desc_manage_bookings": "All actions on bookings",
"pbac_desc_view_team_insights": "View team insights",
@@ -4263,7 +4267,8 @@
"booking_history": "Booking history",
"booking_history_description": "View the history of actions performed on this booking",
"booking_audit_action": {
"created": "Created",
"created": "Booked with {{host}}",
"created_with_seat": "Seat Booked with {{host}}",
"cancelled": "Cancelled",
"rescheduled": "Rescheduled {{oldDate}} -> <0>{{newDate}}</0>",
"rescheduled_from": "Rescheduled <0>{{oldDate}}</0> -> {{newDate}}",
@@ -4278,9 +4283,11 @@
"location_changed": "Location changed",
"location_changed_from_to": "Location changed from {{fromLocation}} to {{toLocation}}",
"attendee_no_show_updated": "Attendee no-show updated",
"type": "Assignment type",
"assignmentType_manual": "Manual assignment",
"assignmentType_roundRobin": "Round robin assignment",
"seat_booked": "Seat booked",
"seat_rescheduled": "Seat rescheduled {{oldDate}} -> <0>{{newDate}}</0>",
"assignment_type": "Assignment",
"assignment_type_manual": "Manual",
"assignment_type_round_robin": "Round robin",
"actor_impersonated_by": "Impersonator",
"source": "Source"
},