1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-22 10:22:39 +01:00

fix my shit

This commit is contained in:
Madeline 2022-09-21 15:16:57 +10:00
parent e88f72c4f0
commit 9506d50782

View File

@ -9,7 +9,7 @@ export interface UserGuildSettingsSchema extends Partial<UserGuildSettings> { }
// GET doesn't exist on discord.com
router.get("/", route({}), async (req: Request, res: Response) => {
const user = await Member.findOneOrFail({
where: { id: req.user_id },
where: { id: req.user_id, guild_id: req.params.guild_id },
select: ["settings"]
});
return res.json(user.settings);
@ -18,7 +18,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
router.patch("/", route({ body: "UserSettingsSchema" }), async (req: Request, res: Response) => {
const body = req.body as UserGuildSettings;
const user = await Member.findOneOrFail({ where: { id: req.user_id } });
const user = await Member.findOneOrFail({ where: { id: req.user_id, guild_id: req.params.guild_id } });
user.settings = { ...user.settings, ...body };
await user.save();