fix updating already deleted booking (#5201)

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: alannnc <alannnc@gmail.com>
This commit is contained in:
authored and GitHub committed 2022-10-25 19:16:16 +00:00
1 parent 3fa52b0600
commit 352ce35b40
2 files changed
+13 -10

No files matched your search

+12 -9
View File
@@ -49,7 +49,8 @@ export async function scheduleTrigger(
export async function cancelScheduledJobs(
booking: { uid: string; scheduledJobs?: string[] },
appId?: string | null
appId?: string | null,
isReschedule?: boolean
) {
let scheduledJobs = booking.scheduledJobs || [];
@@ -70,14 +71,16 @@ export async function cancelScheduledJobs(
scheduledJobs = [];
}
await prisma.booking.update({
where: {
uid: booking.uid,
},
data: {
scheduledJobs: scheduledJobs,
},
});
if (!isReschedule) {
await prisma.booking.update({
where: {
uid: booking.uid,
},
data: {
scheduledJobs: scheduledJobs,
},
});
}
});
}
}
@@ -887,7 +887,7 @@ async function handler(req: NextApiRequest & { userId?: number | undefined }) {
subscribersMeetingEnded.forEach((subscriber) => {
if (rescheduleUid && originalRescheduledBooking) {
cancelScheduledJobs(originalRescheduledBooking);
cancelScheduledJobs(originalRescheduledBooking, undefined, true);
}
if (booking && booking.status === BookingStatus.ACCEPTED) {
scheduleTrigger(booking, subscriber.subscriberUrl, subscriber);