diff --git a/src/lib/import/version3/validateExport.ts b/src/lib/import/version3/validateExport.ts index 6494b9a2e..59c1c79df 100644 --- a/src/lib/import/version3/validateExport.ts +++ b/src/lib/import/version3/validateExport.ts @@ -181,7 +181,7 @@ export const export3Schema = z.object({ z.object({ username: z.string(), password: z.string(), - avatar: z.string(), + avatar: z.string().optional().nullable(), administrator: z.boolean(), super_administrator: z.boolean(), embed: z.object({ @@ -206,12 +206,12 @@ export const export3Schema = z.object({ files: z.record( z.object({ name: z.string(), - original_name: z.string().nullable(), + original_name: z.string().optional().nullable(), type: z.string(), size: z.union([z.number(), z.bigint()]), - user: z.string().nullable(), + user: z.string().optional().nullable(), thumbnail: z.string().optional().nullable(), - max_views: z.number().nullable(), + max_views: z.number().optional().nullable(), views: z.number(), expires_at: z.string().optional().nullable(), created_at: z.string(), @@ -232,7 +232,7 @@ export const export3Schema = z.object({ name: z.string(), public: z.boolean(), created_at: z.string(), - user: z.string(), + user: z.string().optional().nullable(), files: z.array(z.string()), }), ), @@ -243,19 +243,19 @@ export const export3Schema = z.object({ vanity: z.string().optional().nullable(), code: z.string(), created_at: z.string(), - max_views: z.number(), + max_views: z.number().optional().nullable(), views: z.number(), - user: z.string(), + user: z.string().optional().nullable(), }), ), invites: z.record( z.object({ code: z.string(), - expites_at: z.string().optional().nullable(), + expires_at: z.string().optional().nullable(), created_at: z.string(), used: z.boolean(), - created_by_user: z.string(), + created_by_user: z.string().optional().nullable(), }), ), diff --git a/src/server/routes/api/server/import/v3.ts b/src/server/routes/api/server/import/v3.ts index 64d6e8943..fbbb93fb1 100644 --- a/src/server/routes/api/server/import/v3.ts +++ b/src/server/routes/api/server/import/v3.ts @@ -123,7 +123,7 @@ export default fastifyPlugin( const filesImportedToId: Record = {}; for (const [id, file] of Object.entries(export3.files)) { - const user = usersImportedToId[file.user || '']; + const user = file.user ? usersImportedToId[file.user] : undefined; if (!user) { logger.warn('failed to find user for file, skipping', { file: id }); @@ -170,7 +170,7 @@ export default fastifyPlugin( const foldersImportedToId: Record = {}; for (const [id, folder] of Object.entries(export3.folders)) { - const user = usersImportedToId[folder.user]; + const user = folder.user ? usersImportedToId[folder.user] : undefined; if (!user) { logger.warn('failed to find user for folder, skipping', { folder: id }); @@ -207,7 +207,7 @@ export default fastifyPlugin( const urlsImportedToId: Record = {}; for (const [id, url] of Object.entries(export3.urls)) { - const user = usersImportedToId[url.user]; + const user = url.user ? usersImportedToId[url.user] : undefined; if (!user) { logger.warn('failed to find user for url, skipping', { url: id });