🩹 back: patch document retreival for application users with non UUID name #747

This commit is contained in:
Eric Doughty-Papassideris
2024-11-27 15:46:44 +01:00
parent ec3d52589e
commit 55dc20025a
@@ -50,8 +50,19 @@ export const isSharedWithMeFolder = (id: string) => {
export const getVirtualFoldersNames = async (id: string, context: DriveExecutionContext) => {
const configuration = new Configuration("drive");
const defaultLang = configuration.get<string>("defaultLanguage") || "en";
const locale = await (async () => {
try {
const user = await gr.services.users.get({ id: context.user?.id });
const locale = user?.preferences?.locale || defaultLang;
return user?.preferences?.locale || defaultLang;
} catch (error) {
logger.error(
{ error, context },
"Ignoring error getting user to translate root. This is expected from requests coming from applications as the user id is not a valid UUID for postgres. Defaulting to " +
defaultLang,
);
return defaultLang;
}
})();
if (id.startsWith("user_")) {
return gr.services.i18n.translate("virtual-folder.my-drive", locale);