Try to list calendars, if not continue (#10720)

Co-authored-by: Omar López <zomars@me.com>
pull/10728/head
Joe Au-Yeung 2023-08-11 17:19:26 -04:00 committed by GitHub
parent ceb18167cf
commit 8356cb7d34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 12 deletions

View File

@ -304,22 +304,26 @@ export const deleteCredentialHandler = async ({ ctx, input }: DeleteCredentialOp
// If it's a calendar remove it from the SelectedCalendars
if (credential.app?.categories.includes(AppCategories.calendar)) {
const calendar = await getCalendar(credential);
try {
const calendar = await getCalendar(credential);
const calendars = await calendar?.listCalendars();
const calendars = await calendar?.listCalendars();
if (calendars && calendars.length > 0) {
calendars.map(async (cal) => {
await prisma.selectedCalendar.delete({
where: {
userId_integration_externalId: {
userId: user.id,
externalId: cal.externalId,
integration: cal.integration as string,
if (calendars && calendars.length > 0) {
calendars.map(async (cal) => {
await prisma.selectedCalendar.delete({
where: {
userId_integration_externalId: {
userId: user.id,
externalId: cal.externalId,
integration: cal.integration as string,
},
},
},
});
});
});
}
} catch {
console.log(`Error deleting selected calendars for user ${user.id} and calendar ${credential.appId}`);
}
}