Fixed Google Calendar custom destination calendar deletion (#1486)
Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Omar López <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
4 files changed
+10
-6
No files matched your search
@@ -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({});
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
|
||||
+3
-1
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user