Hotfix: Unrelated bookings marked as cancelled due to recurring event (#3427)

* Fix updatedAt not updating

* Fix accidental cacnellation of all bookings if recurringEventId is null

* Update apps/web/pages/api/cancel.ts

Co-authored-by: Syed Ali Shahbaz <[email protected]>

* Fix linting

* Linting warnings

Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: zomars <[email protected]>
This commit is contained in:
authored and GitHub committed 2022-07-19 11:06:43 -06:00
1 parent 2b7f7a06ac
commit f40b035ff8
1 file changed
+3 -4
+3 -4
View File
@@ -6,7 +6,6 @@ import {
PrismaPromise,
WorkflowMethods,
} from "@prisma/client";
import { WorkflowTriggerEvents, WorkflowActions } from "@prisma/client";
import async from "async";
import { NextApiRequest, NextApiResponse } from "next";
@@ -170,11 +169,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
// by cancelling first, and blocking whilst doing so; we can ensure a cancel
// action always succeeds even if subsequent integrations fail cancellation.
if (bookingToDelete.eventType?.recurringEvent) {
const recurringEventId = bookingToDelete.recurringEventId;
const where = recurringEventId === null ? { uid } : { recurringEventId };
// Proceed to mark as cancelled all recurring event instances
await prisma.booking.updateMany({
where: {
recurringEventId: bookingToDelete.recurringEventId,
},
where,
data: {
status: BookingStatus.CANCELLED,
cancellationReason: cancellationReason,