Attach credential id to destinationCalendar records (#3197)
This commit is contained in:
1 parent
2cbf46a323
commit
201d17264c
8 files changed
+31
-1
No files matched your search
@@ -550,7 +550,11 @@ const loggedInViewerRouter = createProtectedRouter()
|
||||
const connectedCalendars = await getConnectedCalendars(calendarCredentials, user.selectedCalendars);
|
||||
const allCals = connectedCalendars.map((cal) => cal.calendars ?? []).flat();
|
||||
|
||||
if (!allCals.find((cal) => cal.externalId === externalId && cal.integration === integration)) {
|
||||
const credentialId = allCals.find(
|
||||
(cal) => cal.externalId === externalId && cal.integration === integration && cal.readOnly === false
|
||||
)?.credentialId;
|
||||
|
||||
if (!credentialId) {
|
||||
throw new TRPCError({ code: "BAD_REQUEST", message: `Could not find calendar ${input.externalId}` });
|
||||
}
|
||||
|
||||
@@ -565,11 +569,13 @@ const loggedInViewerRouter = createProtectedRouter()
|
||||
update: {
|
||||
integration,
|
||||
externalId,
|
||||
credentialId,
|
||||
},
|
||||
create: {
|
||||
...where,
|
||||
integration,
|
||||
externalId,
|
||||
credentialId,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user