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 <zomars@me.com>
This commit is contained in:
Hariom Balhara 2022-07-19 22:36:43 +05:30 committed by GitHub
parent 2b7f7a06ac
commit f40b035ff8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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,