user admin visible
This commit is contained in:
@@ -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 ");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user