Skip to content

Commit

Permalink
fix updating already deleted booking (calcom#5201)
Browse files Browse the repository at this point in the history
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: alannnc <alannnc@gmail.com>
  • Loading branch information
3 people authored and haffla committed Nov 22, 2022
1 parent eaaae24 commit bbffa44
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions packages/app-store/zapier/lib/nodeScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 || [];

Expand All @@ -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,
},
});
}
});
}
}
2 changes: 1 addition & 1 deletion packages/features/bookings/lib/handleNewBooking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,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);
Expand Down

0 comments on commit bbffa44

Please sign in to comment.