list of room users
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 }[];
|
||||
|
||||
Reference in New Issue
Block a user