Add Google cal extneral calendar id to booking reference (#2671)
* Set google cal event id to use our uid * Save calendar external id to bookingRef * Pass external calendar ids to update and delete * Create migration * Fix type errors * Fix prisma url Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Omar López <[email protected]>
This commit is contained in:
8 files changed
+30
-14
No files matched your search
@@ -128,7 +128,8 @@ export const createEvent = async (credential: Credential, calEvent: CalendarEven
|
||||
export const updateEvent = async (
|
||||
credential: Credential,
|
||||
calEvent: CalendarEvent,
|
||||
bookingRefUid: string | null
|
||||
bookingRefUid: string | null,
|
||||
externalCalendarId: string | null
|
||||
): Promise<EventResult> => {
|
||||
const uid = getUid(calEvent);
|
||||
const calendar = getCalendar(credential);
|
||||
@@ -139,7 +140,7 @@ export const updateEvent = async (
|
||||
const updatedResult =
|
||||
calendar && bookingRefUid
|
||||
? await calendar
|
||||
.updateEvent(bookingRefUid, calEvent)
|
||||
.updateEvent(bookingRefUid, calEvent, externalCalendarId)
|
||||
.then(() => (success = true))
|
||||
.catch((e) => {
|
||||
log.error("updateEvent failed", e, calEvent);
|
||||
|
||||
@@ -146,6 +146,7 @@ export default class EventManager {
|
||||
meetingId: result.createdEvent?.id.toString(),
|
||||
meetingPassword: result.createdEvent?.password,
|
||||
meetingUrl: result.createdEvent?.url,
|
||||
externalCalendarId: evt.destinationCalendar?.externalId,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -188,6 +189,7 @@ export default class EventManager {
|
||||
meetingId: true,
|
||||
meetingPassword: true,
|
||||
meetingUrl: true,
|
||||
externalCalendarId: true,
|
||||
},
|
||||
},
|
||||
destinationCalendar: true,
|
||||
@@ -354,7 +356,11 @@ export default class EventManager {
|
||||
? booking.references.filter((ref) => ref.type === credential.type && !!ref.uid)[0]?.uid
|
||||
: null;
|
||||
|
||||
return updateEvent(credential, event, bookingRefUid);
|
||||
const bookingExternalCalendarId = booking.references
|
||||
? booking.references.filter((ref) => ref.type === credential.type)[0].externalCalendarId
|
||||
: null;
|
||||
|
||||
return updateEvent(credential, event, bookingRefUid, bookingExternalCalendarId!);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user