user admin visible

This commit is contained in:
simplonco
2023-01-15 20:45:03 +01:00
parent 77c420a174
commit b4bdc2080b
4 changed files with 41 additions and 7 deletions

View File

@@ -412,14 +412,27 @@ export class ChatController {
const room_name = await this.chatService.getCurrentRoomName(req.user.username);
const room = await this.chatService.getRoomByName(room_name);
const users = room.users;
const admins = room.admins;
let index = users.indexOf(req.user.username);
if (index > -1)
{
users.splice(index, 1);
}
res.status(HttpStatus.OK).json({ users: users });
let ret_users = users.map(username =>
{
let new_user =
{
name: username,
isadmin: false,
};
if (admins.includes(username))
new_user.isadmin = true;
return new_user;
});
console.log("ret_user:", ret_users);
res.status(HttpStatus.OK).json({ users: ret_users });
printCaller("- out ");
}