diff options
author | Nobody <17956512+n0bodysec@users.noreply.github.com> | 2022-03-08 12:15:38 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-08 12:15:38 -0300 |
commit | c1b22dc541499c667b50743d1ffa3c0d968dad4b (patch) | |
tree | 7a071e4bde02eb5808c4ac7917d67677a844ebe2 /api/src | |
parent | fix(api): working ban list (diff) | |
parent | Temporary notes fix (diff) | |
download | server-c1b22dc541499c667b50743d1ffa3c0d968dad4b.tar.xz |
Merge branch 'master' into fix/ban-list
Diffstat (limited to 'api/src')
-rw-r--r-- | api/src/routes/guilds/#guild_id/members/#member_id/index.ts | 6 | ||||
-rw-r--r-- | api/src/routes/users/@me/notes.ts | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts index 24c74af7..34836292 100644 --- a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts +++ b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts @@ -25,13 +25,19 @@ router.patch("/", route({ body: "MemberChangeSchema" }), async (req: Request, re const member = await Member.findOneOrFail({ where: { id: member_id, guild_id }, relations: ["roles", "user"] }); const permission = await getPermission(req.user_id, guild_id); + const everyone = await Role.findOneOrFail({ guild_id: guild_id, name: "@everyone", position: 0 }); if (body.roles) { permission.hasThrow("MANAGE_ROLES"); + + if (body.roles.indexOf(everyone.id) === -1) body.roles.push(everyone.id); member.roles = body.roles.map((x) => new Role({ id: x })); // foreign key constraint will fail if role doesn't exist } await member.save(); + + member.roles = member.roles.filter((x) => x.id !== everyone.id); + // do not use promise.all as we have to first write to db before emitting the event to catch errors await emitEvent({ event: "GUILD_MEMBER_UPDATE", diff --git a/api/src/routes/users/@me/notes.ts b/api/src/routes/users/@me/notes.ts index 2ef27bc0..96067bf5 100644 --- a/api/src/routes/users/@me/notes.ts +++ b/api/src/routes/users/@me/notes.ts @@ -6,9 +6,9 @@ const router: Router = Router(); router.put("/:id", route({}), async (req: Request, res: Response) => { //TODO res.json({ - message: "400: Bad Request", - code: 0 - }).status(400); + message: "Unknown User", + code: 10013 + }).status(404); }); export default router; |