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
@@ -51,6 +51,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
select: {
|
||||
uid: true,
|
||||
type: true,
|
||||
externalCalendarId: true,
|
||||
},
|
||||
},
|
||||
payment: true,
|
||||
@@ -163,11 +164,14 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
|
||||
const apiDeletes = async.mapLimit(bookingToDelete.user.credentials, 5, async (credential: Credential) => {
|
||||
const bookingRefUid = bookingToDelete.references.filter((ref) => ref.type === credential.type)[0]?.uid;
|
||||
const bookingExternalCalendarId = bookingToDelete.references.filter(
|
||||
(ref) => ref.type === credential.type
|
||||
)[0]?.externalCalendarId;
|
||||
if (bookingRefUid) {
|
||||
if (credential.type.endsWith("_calendar")) {
|
||||
const calendar = getCalendar(credential);
|
||||
|
||||
return calendar?.deleteEvent(bookingRefUid, evt);
|
||||
return calendar?.deleteEvent(bookingRefUid, evt, bookingExternalCalendarId);
|
||||
} else if (credential.type.endsWith("_video")) {
|
||||
return deleteMeeting(credential, bookingRefUid);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user