mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-12-03 03:12:51 +08:00
feat: reorganize settings and add synced appearance preferences
This commit is contained in:
1 parent
28c128d0c9
commit
8d750d19b0
30 files changed
+835
-98
No files matched your search
@@ -182,9 +182,27 @@ export function createSessionRouter(
|
||||
capabilities: [...ctx.capabilities],
|
||||
bots: ctx.bots === "all" ? "all" : [...ctx.bots],
|
||||
guest: ctx.guest ?? null,
|
||||
accentColor: user.role === "guest" ? null : users.getAccentColor(user.id),
|
||||
});
|
||||
});
|
||||
|
||||
router.put("/preferences", requireAuthInline, (req, res) => {
|
||||
if (req.user!.role === "guest") {
|
||||
res.status(403).json({ error: "guests store appearance preferences locally" });
|
||||
return;
|
||||
}
|
||||
const color = req.body?.accentColor;
|
||||
if (typeof color !== "string" || !/^#[0-9a-fA-F]{6}$/.test(color)) {
|
||||
res.status(400).json({ error: "invalid accent color" });
|
||||
return;
|
||||
}
|
||||
if (!users.setAccentColor(req.user!.id, color.toLowerCase())) {
|
||||
res.status(404).json({ error: "user not found" });
|
||||
return;
|
||||
}
|
||||
res.json({ accentColor: color.toLowerCase() });
|
||||
});
|
||||
|
||||
router.post("/change-password", requireAuthInline, async (req, res) => {
|
||||
const { oldPassword, newPassword } = req.body ?? {};
|
||||
if (typeof oldPassword !== "string") {
|
||||
|
||||
Reference in new issue
Block a user