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

Allow nicknames through MemberChangeSchema

This commit is contained in:
Madeline 2022-07-03 01:23:54 +10:00
parent 4fbebe17d3
commit 6a583fb88c
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
2 changed files with 2028 additions and 525 deletions

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,7 @@ const router = Router();
export interface MemberChangeSchema {
roles?: string[];
nick?: string;
}
router.get("/", route({}), async (req: Request, res: Response) => {
@ -34,6 +35,8 @@ router.patch("/", route({ body: "MemberChangeSchema" }), async (req: Request, re
member.roles = body.roles.map((x) => new Role({ id: x })); // foreign key constraint will fail if role doesn't exist
}
if (body.nick) member.nick = body.nick;
await member.save();
member.roles = member.roles.filter((x) => x.id !== everyone.id);