summary refs log tree commit diff
path: root/src/api/routes/users
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-12 01:46:42 +0200
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-12-19 17:52:44 +1100
commit803ab38fad68d62493dfd8395f5160ac8176a1b5 (patch)
tree75994ec356061d62bce0b948167d93587a04bc6d /src/api/routes/users
parentAdd additional config (diff)
downloadserver-803ab38fad68d62493dfd8395f5160ac8176a1b5.tar.xz
Move UserSettings to own entity
Diffstat (limited to 'src/api/routes/users')
-rw-r--r--src/api/routes/users/@me/settings.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/api/routes/users/@me/settings.ts b/src/api/routes/users/@me/settings.ts
index 8fb86012..0fd8220a 100644
--- a/src/api/routes/users/@me/settings.ts
+++ b/src/api/routes/users/@me/settings.ts
@@ -7,7 +7,7 @@ const router = Router();
 router.get("/", route({}), async (req: Request, res: Response) => {
 	const user = await User.findOneOrFail({
 		where: { id: req.user_id },
-		select: ["settings"],
+		relations: ["settings"],
 	});
 	return res.json(user.settings);
 });
@@ -21,10 +21,12 @@ router.patch(
 
 		const user = await User.findOneOrFail({
 			where: { id: req.user_id, bot: false },
-			select: ["settings"]
+			relations: ["settings"]
 		});
-		user.settings = OrmUtils.mergeDeep(user.settings, body);
-		User.update({ id: user.id }, { settings: user.settings });
+
+		user.settings.assign(body);
+
+		user.settings.save();
 
 		res.json(user.settings);
 	},