75d611c2e8
* Integrate creation/rescheduling booking audit * fix: add missing hostUserUuid to booking audit test data Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * 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: hariom@cal.com <hariombalhara@gmail.com> * 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>
68 lines
2.0 KiB
TypeScript
68 lines
2.0 KiB
TypeScript
import {
|
|
makeAttendeeActor,
|
|
makeUserActor,
|
|
makeGuestActor,
|
|
} from "@calcom/features/booking-audit/lib/makeActor";
|
|
import { ISimpleLogger } from "@calcom/features/di/shared/services/logger.service";
|
|
import { safeStringify } from "@calcom/lib/safeStringify";
|
|
/**
|
|
* Used to create actor for new booking/reschedule booking scenarios
|
|
*/
|
|
export function getBookingAuditActorForNewBooking({
|
|
bookerAttendeeId,
|
|
actorUserUuid,
|
|
rescheduledBy,
|
|
bookerEmail,
|
|
logger,
|
|
bookerName,
|
|
}: {
|
|
bookerAttendeeId: number | null;
|
|
actorUserUuid: string | null;
|
|
bookerEmail: string;
|
|
bookerName: string;
|
|
logger: ISimpleLogger;
|
|
rescheduledBy:
|
|
| {
|
|
attendeeId: number | null;
|
|
email: string;
|
|
}
|
|
| {
|
|
userUuid: string | null;
|
|
email: string;
|
|
}
|
|
| null;
|
|
}) {
|
|
if (actorUserUuid) {
|
|
return makeUserActor(actorUserUuid);
|
|
}
|
|
|
|
if (rescheduledBy) {
|
|
// If rescheduledBy is available we prefer that above considering booker as the actor
|
|
if ("attendeeId" in rescheduledBy && rescheduledBy.attendeeId) {
|
|
return makeAttendeeActor(rescheduledBy.attendeeId);
|
|
}
|
|
|
|
if ("userUuid" in rescheduledBy && rescheduledBy.userUuid) {
|
|
// We consider that a user actor did it without verifying the authorization, so whn taking the action we could record in the context that this action was taken through rescheduledBy contex, similar to how we would do impersonatedBy in context
|
|
// as introduced in PR: https://github.com/calcom/cal.com/pull/26014
|
|
return makeUserActor(rescheduledBy.userUuid);
|
|
}
|
|
|
|
return makeGuestActor({ email: rescheduledBy.email, name: rescheduledBy.email });
|
|
}
|
|
|
|
if (bookerAttendeeId) {
|
|
return makeAttendeeActor(bookerAttendeeId);
|
|
}
|
|
|
|
// Ideally we should have attendeeId atleast but for some unforeseen case we don't, we must create a guest actor.
|
|
logger.warn(
|
|
"Creating guest actor for booking audit",
|
|
safeStringify({
|
|
email: bookerEmail,
|
|
})
|
|
);
|
|
|
|
return makeGuestActor({ email: bookerEmail, name: bookerName });
|
|
}
|