Scheduling infrastructure for absolutely everyone.
Fixed Google Calendar custom destination calendar deletion (#1486)
Philip Niedertscheider9c94aadbf7af
diff --git a/lib/integrations/calendar/CalendarManager.ts b/lib/integrations/calendar/CalendarManager.tsindex 961b9cfc87c..7f24ae8dca3 100644--- a/lib/integrations/calendar/CalendarManager.ts+++ b/lib/integrations/calendar/CalendarManager.ts@@ -170,10 +170,10 @@ export const updateEvent = async (};};-export const deleteEvent = (credential: Credential, uid: string): Promise<unknown> => {+export const deleteEvent = (credential: Credential, uid: string, event: CalendarEvent): Promise<unknown> => {const calendar = getCalendar(credential);if (calendar) {- return calendar.deleteEvent(uid);+ return calendar.deleteEvent(uid, event);}return Promise.resolve({});diff --git a/lib/integrations/calendar/interfaces/Calendar.ts b/lib/integrations/calendar/interfaces/Calendar.tsindex f9358e6a3bf..fe6284c3d8c 100644--- a/lib/integrations/calendar/interfaces/Calendar.ts+++ b/lib/integrations/calendar/interfaces/Calendar.ts@@ -66,7 +66,7 @@ export interface Calendar {updateEvent(uid: string, event: CalendarEvent): Promise<any>;- deleteEvent(uid: string): Promise<unknown>;+ deleteEvent(uid: string, event: CalendarEvent): Promise<unknown>;getAvailability(dateFrom: string,diff --git a/lib/integrations/calendar/services/GoogleCalendarService.ts b/lib/integrations/calendar/services/GoogleCalendarService.tsindex 55f68dc9643..9eb2b96a753 100644--- a/lib/integrations/calendar/services/GoogleCalendarService.ts+++ b/lib/integrations/calendar/services/GoogleCalendarService.ts@@ -185,7 +185,7 @@ export default class GoogleCalendarService implements Calendar {);}- async deleteEvent(uid: string): Promise<void> {+ async deleteEvent(uid: string, event: CalendarEvent): Promise<void> {return new Promise((resolve, reject) =>this.auth.getToken().then((myGoogleAuth) => {const calendar = google.calendar({@@ -195,7 +195,9 @@ export default class GoogleCalendarService implements Calendar {calendar.events.delete({auth: myGoogleAuth,- calendarId: "primary",+ calendarId: event.destinationCalendar?.externalId+ ? event.destinationCalendar.externalId+ : "primary",eventId: uid,sendNotifications: true,sendUpdates: "all",diff --git a/pages/api/cancel.ts b/pages/api/cancel.tsindex a12a24bf55e..9c660678f2d 100644--- a/pages/api/cancel.ts+++ b/pages/api/cancel.ts@@ -40,6 +40,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)email: true,timeZone: true,name: true,+ destinationCalendar: true,},},attendees: true,@@ -105,6 +106,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)uid: bookingToDelete?.uid,location: bookingToDelete?.location,language: t,+ destinationCalendar: bookingToDelete?.user.destinationCalendar,};// Hook up the webhook logic here@@ -141,7 +143,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)if (credential.type.endsWith("_calendar")) {const calendar = getCalendar(credential);- return calendar?.deleteEvent(bookingRefUid);+ return calendar?.deleteEvent(bookingRefUid, evt);} else if (credential.type.endsWith("_video")) {return deleteMeeting(credential, bookingRefUid);}