Fix reschedule not happening in calendar if two calendards are there (#2733)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
authored and GitHub committed 2022-05-12 09:33:15 +00:00
1 parent 574f9cb5d4
commit 7a08403636
3 files changed
+18 -10

No files matched your search

+11 -7
View File
@@ -132,15 +132,19 @@ export const updateEvent = async (
): Promise<EventResult> => {
const uid = getUid(calEvent);
const calendar = getCalendar(credential);
let success = true;
let success = false;
if (bookingRefUid === "") {
log.error("updateEvent failed", "bookingRefUid is empty", calEvent, credential);
}
const updatedResult =
calendar && bookingRefUid
? await calendar.updateEvent(bookingRefUid, calEvent).catch((e) => {
log.error("updateEvent failed", e, calEvent);
success = false;
return undefined;
})
? await calendar
.updateEvent(bookingRefUid, calEvent)
.then(() => (success = true))
.catch((e) => {
log.error("updateEvent failed", e, calEvent);
return undefined;
})
: undefined;
return {
+6 -1
View File
@@ -345,8 +345,13 @@ export default class EventManager {
booking: PartialBooking
): Promise<Array<EventResult>> {
return async.mapLimit(this.calendarCredentials, 5, async (credential: Credential) => {
// HACK:
// Right now if two calendars are connected and a booking is created it has two bookingReferences, one is having uid null and the other is having valid uid.
// I don't know why yet - But we should work on fixing that. But even after the fix as there can be multiple references in an existing booking the following ref.uid check would still be required
// We should ignore the one with uid null, the other one is valid.
// Also, we should store(if not already) that which is the calendarCredential for the valid bookingReference, instead of going through all credentials one by one
const bookingRefUid = booking
? booking.references.filter((ref) => ref.type === credential.type)[0]?.uid
? booking.references.filter((ref) => ref.type === credential.type && !!ref.uid)[0]?.uid
: null;
return updateEvent(credential, event, bookingRefUid);