Skip to content

Commit

Permalink
creating default event-types should set the user's default location
Browse files Browse the repository at this point in the history
  • Loading branch information
SomayChauhan committed Jun 10, 2024
1 parent 612b6e4 commit 20fdb50
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,16 @@ async function getDefaultLocations(user: User): Promise<EventTypeLocation[]> {
const defaultConferencingData = userMetadataSchema.parse(user.metadata)?.defaultConferencingApp;
const appKeys = await getAppKeysFromSlug("daily-video");

if (typeof appKeys.api_key === "string") {
return [{ type: DailyLocationType }];
}

if (defaultConferencingData && defaultConferencingData.appSlug !== "daily-video") {
const credentials = await getUsersCredentials(user);
const foundApp = getApps(credentials, true).filter(
(app) => app.slug === defaultConferencingData.appSlug
)[0]; // There is only one possible install here so index [0] is the one we are looking for ;
const locationType = foundApp?.locationOption?.value ?? DailyLocationType; // Default to Daily if no location type is found
return [{ type: locationType, link: defaultConferencingData.appLink }];
const credentialId = foundApp.credential.id ?? undefined;
return [{ type: locationType, link: defaultConferencingData.appLink, credentialId }];
} else if (typeof appKeys.api_key === "string") {
return [{ type: DailyLocationType }];
}

return [];
Expand Down

0 comments on commit 20fdb50

Please sign in to comment.