summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-10-28 19:23:02 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-10-28 19:23:02 +1100
commit4c58a8bc249856a3e3b0af02ac086226a9308ddc (patch)
tree65ababbcb6915bf2e686d003383ce5ea573289df /src/api
parentlol (diff)
downloadserver-4c58a8bc249856a3e3b0af02ac086226a9308ddc.tar.xz
Fix user settings not saving properly and guild folders
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/users/@me/settings.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/api/routes/users/@me/settings.ts b/src/api/routes/users/@me/settings.ts
index 4493fcc7..8fb86012 100644
--- a/src/api/routes/users/@me/settings.ts
+++ b/src/api/routes/users/@me/settings.ts
@@ -1,5 +1,5 @@
 import { Router, Response, Request } from "express";
-import { User, UserSettings } from "@fosscord/util";
+import { OrmUtils, User, UserSettingsSchema } from "@fosscord/util";
 import { route } from "@fosscord/api";
 
 const router = Router();
@@ -16,14 +16,15 @@ router.patch(
 	"/",
 	route({ body: "UserSettingsSchema" }),
 	async (req: Request, res: Response) => {
-		const body = req.body as UserSettings;
+		const body = req.body as UserSettingsSchema;
 		if (body.locale === "en") body.locale = "en-US"; // fix discord client crash on unkown locale
 
 		const user = await User.findOneOrFail({
 			where: { id: req.user_id, bot: false },
+			select: ["settings"]
 		});
-		user.settings = { ...user.settings, ...body };
-		await user.save();
+		user.settings = OrmUtils.mergeDeep(user.settings, body);
+		User.update({ id: user.id }, { settings: user.settings });
 
 		res.json(user.settings);
 	},