fix: Can cancel an already cancelled booking through the API (#22128)
* fix: can cancel already cancelled booking * add test * fix test * update * Update bookings.service.ts * add commnet * update * tweak
This commit is contained in:
1 parent
b599ce4919
commit
aa3086cfae
5 files changed
+82
No files matched your search
@@ -100,6 +100,7 @@ export async function getBookingToDelete(id: number | undefined, uid: string | u
|
||||
responses: true,
|
||||
iCalUID: true,
|
||||
iCalSequence: true,
|
||||
status: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -89,6 +89,19 @@ async function handler(input: CancelBookingInput) {
|
||||
arePlatformEmailsEnabled,
|
||||
} = input;
|
||||
|
||||
/**
|
||||
* Important: We prevent cancelling an already cancelled booking.
|
||||
* A booking could have been CANCELLED due to a reschedule,
|
||||
* in which case we simply update the existing calendar event and meeting.
|
||||
* We want to avoid deleting them by a subsequent cancellation attempt.
|
||||
*/
|
||||
if (bookingToDelete.status === BookingStatus.CANCELLED) {
|
||||
throw new HttpError({
|
||||
statusCode: 400,
|
||||
message: "This booking has already been cancelled.",
|
||||
});
|
||||
}
|
||||
|
||||
if (!bookingToDelete.userId || !bookingToDelete.user) {
|
||||
throw new HttpError({ statusCode: 400, message: "User not found" });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user