list of room users

This commit is contained in:
hugogogo
2023-01-09 20:52:59 +01:00
parent 5184097765
commit eea631b18a
11 changed files with 587 additions and 234 deletions

View File

@@ -102,5 +102,18 @@ export class ChatController {
return res.status(HttpStatus.OK).json({ messages: messages });
}
@UseGuards(AuthenticateGuard)
@UseGuards(TwoFactorGuard)
@Get('roomusers')
async getRoomUsers(@Req() req, @Res() res): Promise<object>
{
console.log("- in getRoomUsers controller");
const current_room = await this.chatService.getCurrentRoom(req.user.username);
const room = await this.chatService.getRoomByName(current_room);
const users = room.users;
console.log("- out getRoomUsers controller");
return res.status(HttpStatus.OK).json({ users: users });
}
}

View File

@@ -83,6 +83,7 @@ export class ChatService {
async getCurrentRoom(username: string)
{
console.log("-- in getCurrentRoom service");
console.log('username:', username);
const user_db = await this.getUserByName(username);
//const user_db = await this.usersService.findOne(username);

View File

@@ -27,10 +27,10 @@ export class Chatroom {
// users: User[];
@Column()
owner: string; // name
owner: string; // username
@Column("simple-array")
users: string[]; // names
users: string[]; // usernames
@Column("json")
messages: { name: string, message: string }[];