perf: Refactor getEnabledApps to filter on credentials passed (#10353)
Co-authored-by: Omar López <[email protected]> Co-authored-by: Hariom Balhara <[email protected]>
This commit is contained in:
20 files changed
+76
-27
No files matched your search
@@ -114,7 +114,7 @@ export const integrationsHandler = async ({ ctx, input }: IntegrationsOptions) =
|
||||
}
|
||||
}
|
||||
|
||||
const enabledApps = await getEnabledApps(credentials);
|
||||
const enabledApps = await getEnabledApps(credentials, onlyInstalled);
|
||||
//TODO: Refactor this to pick up only needed fields and prevent more leaking
|
||||
let apps = enabledApps.map(
|
||||
({ credentials: _, credential: _1, key: _2 /* don't leak to frontend */, ...app }) => {
|
||||
|
||||
@@ -29,12 +29,13 @@ export const locationOptionsHandler = async ({ ctx, input }: LocationOptionsOpti
|
||||
type: true,
|
||||
key: true,
|
||||
userId: true,
|
||||
teamId: true,
|
||||
appId: true,
|
||||
invalid: true,
|
||||
},
|
||||
});
|
||||
|
||||
const integrations = await getEnabledApps(credentials);
|
||||
const integrations = await getEnabledApps(credentials, true);
|
||||
|
||||
const t = await getTranslation(ctx.user.locale ?? "en", "common");
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ export const updateUserDefaultConferencingAppHandler = async ({
|
||||
}: UpdateUserDefaultConferencingAppOptions) => {
|
||||
const currentMetadata = userMetadata.parse(ctx.user.metadata);
|
||||
const credentials = ctx.user.credentials;
|
||||
const foundApp = getApps(credentials).filter((app) => app.slug === input.appSlug)[0];
|
||||
const foundApp = getApps(credentials, true).filter((app) => app.slug === input.appSlug)[0];
|
||||
const appLocation = foundApp?.appData?.location;
|
||||
|
||||
if (!foundApp || !appLocation) throw new TRPCError({ code: "BAD_REQUEST", message: "App not installed" });
|
||||
|
||||
@@ -25,7 +25,7 @@ export const createHandler = async ({ ctx, input }: CreateOptions) => {
|
||||
const { schedulingType, teamId, metadata, ...rest } = input;
|
||||
const userId = ctx.user.id;
|
||||
const isManagedEventType = schedulingType === SchedulingType.MANAGED;
|
||||
// Get Users default conferncing app
|
||||
// Get Users default conferencing app
|
||||
|
||||
const defaultConferencingData = userMetadataSchema.parse(ctx.user.metadata)?.defaultConferencingApp;
|
||||
const appKeys = await getAppKeysFromSlug("daily-video");
|
||||
@@ -42,7 +42,9 @@ export const createHandler = async ({ ctx, input }: CreateOptions) => {
|
||||
|
||||
if (defaultConferencingData && defaultConferencingData.appSlug !== "daily-video") {
|
||||
const credentials = ctx.user.credentials;
|
||||
const foundApp = getApps(credentials).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 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
|
||||
locations = [{ type: locationType, link: defaultConferencingData.appLink }];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user