Fixing GCal emailing notif and sequential deleting (#6460)

This commit is contained in:
Leo Giovanetti authored and GitHub committed 2023-01-13 11:29:42 -07:00
1 parent ce9413e0dd
commit a4d6f7da62
2 files changed
+6 -5

No files matched your search

@@ -306,15 +306,16 @@ async function handler(req: NextApiRequest & { userId?: number }) {
) {
bookingToDelete.user.credentials
.filter((credential) => credential.type.endsWith("_calendar"))
.forEach((credential) => {
.forEach(async (credential) => {
const calendar = getCalendar(credential);
updatedBookings.forEach((updBooking) => {
for (const updBooking of updatedBookings) {
const bookingRef = updBooking.references.find((ref) => ref.type.includes("_calendar"));
if (bookingRef) {
const { uid, externalCalendarId } = bookingRef;
apiDeletes.push(calendar?.deleteEvent(uid, evt, externalCalendarId) as Promise<unknown>);
const deletedEvent = await calendar?.deleteEvent(uid, evt, externalCalendarId);
apiDeletes.push(deletedEvent);
}
});
}
});
} else {
apiDeletes.push(calendar?.deleteEvent(uid, evt, externalCalendarId) as Promise<unknown>);