wip invite users
This commit is contained in:
@@ -189,5 +189,19 @@ export class ChatController {
|
||||
console.log("- out getRoomUsers controller");
|
||||
}
|
||||
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
@Get('users')
|
||||
async getAllUsers(@Req() req, @Res() res): Promise<void>
|
||||
{
|
||||
console.log("- in getAllUsers controller");
|
||||
|
||||
const room_name = await this.chatService.getCurrentRoomName(req.user.username);
|
||||
const users = await this.chatService.getAllUsersNotInRoom(room_name);
|
||||
res.status(HttpStatus.OK).json({ users: users });
|
||||
|
||||
console.log("- out getAllUsers controller");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -309,6 +309,24 @@ export class ChatService {
|
||||
return users;
|
||||
}
|
||||
|
||||
async getAllUsersNotInRoom(current_room_name: string): Promise<User[]>
|
||||
{
|
||||
console.log("-- in getAllUsersNotInRoom service");
|
||||
|
||||
// get all users in current room
|
||||
const current_room = await this.getRoomByName(current_room_name);
|
||||
const usernames = current_room.users;
|
||||
|
||||
const users = await this.userRepository
|
||||
.createQueryBuilder('user')
|
||||
.where('user.username NOT IN (:...usernames)', { usernames: usernames })
|
||||
.getMany();
|
||||
console.log("--- users:", users);
|
||||
|
||||
console.log("-- out getAllUsersNotInRoom service");
|
||||
return users;
|
||||
}
|
||||
|
||||
|
||||
/* GATEWAY EVENTS *****************************************
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user