Try to list calendars, if not continue (#10720)
Co-authored-by: Omar López <zomars@me.com>pull/10728/head
parent
ceb18167cf
commit
8356cb7d34
|
@ -304,22 +304,26 @@ export const deleteCredentialHandler = async ({ ctx, input }: DeleteCredentialOp
|
||||||
|
|
||||||
// If it's a calendar remove it from the SelectedCalendars
|
// If it's a calendar remove it from the SelectedCalendars
|
||||||
if (credential.app?.categories.includes(AppCategories.calendar)) {
|
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) {
|
if (calendars && calendars.length > 0) {
|
||||||
calendars.map(async (cal) => {
|
calendars.map(async (cal) => {
|
||||||
await prisma.selectedCalendar.delete({
|
await prisma.selectedCalendar.delete({
|
||||||
where: {
|
where: {
|
||||||
userId_integration_externalId: {
|
userId_integration_externalId: {
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
externalId: cal.externalId,
|
externalId: cal.externalId,
|
||||||
integration: cal.integration as string,
|
integration: cal.integration as string,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
} catch {
|
||||||
|
console.log(`Error deleting selected calendars for user ${user.id} and calendar ${credential.appId}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue