wip invite users

This commit is contained in:
simplonco
2023-01-12 12:47:53 +01:00
parent 61191d23b4
commit 83aa46f80c
7 changed files with 137 additions and 1 deletions

View File

@@ -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");
}
}

View File

@@ -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 *****************************************
*/