summary refs log tree commit diff
path: root/api/src/routes/users/@me/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/routes/users/@me/index.ts')
-rw-r--r--api/src/routes/users/@me/index.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/api/src/routes/users/@me/index.ts b/api/src/routes/users/@me/index.ts

index 6a2456d6..8ab30a8d 100644 --- a/api/src/routes/users/@me/index.ts +++ b/api/src/routes/users/@me/index.ts
@@ -2,6 +2,7 @@ import { Router, Request, Response } from "express"; import { User, PrivateUserProjection, emitEvent, UserUpdateEvent, handleFile, FieldErrors } from "@fosscord/util"; import { route } from "@fosscord/api"; import bcrypt from "bcrypt"; +import { OrmUtils } from "@fosscord/util"; const router: Router = Router(); @@ -32,7 +33,8 @@ router.patch("/", route({ body: "UserModifySchema" }), async (req: Request, res: const body = req.body as UserModifySchema; if (body.avatar) body.avatar = await handleFile(`/avatars/${req.user_id}`, body.avatar as string); - if (body.banner) body.banner = await handleFile(`/banners/${req.user_id}`, body.banner as string);let user = await User.findOneOrFail({ where: { id: req.user_id }, select: [...PrivateUserProjection, "data"] }); + if (body.banner) body.banner = await handleFile(`/banners/${req.user_id}`, body.banner as string); + let user = await User.findOneOrFail({ where: { id: req.user_id }, select: [...PrivateUserProjection, "data"] }); if (body.password) { if (user.data?.hash) { @@ -63,7 +65,7 @@ router.patch("/", route({ body: "UserModifySchema" }), async (req: Request, res: } } - user = Object.assign(user, body); + user = OrmUtils.mergeDeep(user, body); await user.save(); // @ts-ignore