fix: Backwards compatibility on google reschedule/cancel (#11733)

pull/11714/head^2
Alex van Andel 2023-10-06 14:27:36 +01:00 committed by GitHub
parent c105793486
commit f9c578c87d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 8 deletions

View File

@ -284,9 +284,10 @@ export default class GoogleCalendarService implements Calendar {
const calendar = await this.authedCalendar();
const selectedCalendar = externalCalendarId
? externalCalendarId
: event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId;
const selectedCalendar =
(externalCalendarId
? event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId
: undefined) || "primary";
try {
const evt = await calendar.events.update({
@ -337,14 +338,15 @@ export default class GoogleCalendarService implements Calendar {
async deleteEvent(uid: string, event: CalendarEvent, externalCalendarId?: string | null): Promise<void> {
const calendar = await this.authedCalendar();
const defaultCalendarId = "primary";
const calendarId = externalCalendarId
? externalCalendarId
: event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId;
const selectedCalendar =
(externalCalendarId
? event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId
: undefined) || "primary";
try {
const event = await calendar.events.delete({
calendarId: calendarId ? calendarId : defaultCalendarId,
calendarId: selectedCalendar,
eventId: uid,
sendNotifications: false,
sendUpdates: "none",