From f40b035ff8de70a448f2a5248a9b89c70f20eea7 Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Tue, 19 Jul 2022 22:36:43 +0530 Subject: [PATCH] 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 <52925846+alishaz-polymath@users.noreply.github.com> * Fix linting * Linting warnings Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: zomars --- apps/web/pages/api/cancel.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/web/pages/api/cancel.ts b/apps/web/pages/api/cancel.ts index bf23f61bb5..3884cd9632 100644 --- a/apps/web/pages/api/cancel.ts +++ b/apps/web/pages/api/cancel.ts @@ -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,