2 files changed, 7 insertions, 3 deletions
diff --git a/api/src/routes/users/@me/settings.ts b/api/src/routes/users/@me/settings.ts
index 4e014126..b22b72fb 100644
--- a/api/src/routes/users/@me/settings.ts
+++ b/api/src/routes/users/@me/settings.ts
@@ -10,8 +10,9 @@ router.patch("/", route({ body: "UserSettingsSchema" }), async (req: Request, re
const body = req.body as UserSettings;
if (body.locale === "en") body.locale = "en-US"; // fix discord client crash on unkown locale
- // only users can update user settings
- await User.update({ id: req.user_id, bot: false }, { settings: body });
+ const user = await User.findOneOrFail({ id: req.user_id, bot: false });
+ user.settings = { ...user.settings, ...body };
+ await user.save();
res.sendStatus(204);
});
diff --git a/api/src/util/Instance.ts b/api/src/util/Instance.ts
index 7dcd126e..6bddfa98 100644
--- a/api/src/util/Instance.ts
+++ b/api/src/util/Instance.ts
@@ -1,4 +1,4 @@
-import { Config, Guild } from "@fosscord/util";
+import { Config, Guild, Session } from "@fosscord/util";
export async function initInstance() {
// TODO: clean up database and delete tombstone data
@@ -15,4 +15,7 @@ export async function initInstance() {
await Config.set({ guild: { autoJoin: { guilds: [guild.id] } } });
}
}
+
+ // TODO: do no clear sessions for instance cluster
+ await Session.delete({});
}
|