Fixing GCal emailing notif and sequential deleting (#6460)

This commit is contained in:
Leo Giovanetti 2023-01-13 15:29:42 -03:00 committed by GitHub
parent ce9413e0dd
commit a4d6f7da62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -273,7 +273,7 @@ export default class GoogleCalendarService implements Calendar {
auth: myGoogleAuth,
calendarId: calendarId ? calendarId : defaultCalendarId,
eventId: uid,
sendNotifications: true,
sendNotifications: false,
sendUpdates: "all",
},
function (err: GoogleCalError | null, event) {

View File

@ -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>);