wip bock user
This commit is contained in:
@@ -525,5 +525,19 @@ export class ChatController {
|
||||
printCaller("- out ");
|
||||
}
|
||||
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
@Post('block')
|
||||
async blockUser(@Body('username') username: string, @Req() req, @Res() res): Promise<void>
|
||||
{
|
||||
printCaller("- in ");
|
||||
|
||||
let user_socket: socketDto = this.chatGateway.sockets.get(req.user.username);
|
||||
user_socket.join(`${username}_not_emit`);
|
||||
|
||||
res.status(HttpStatus.OK).json({ message: "successfull unmute" });
|
||||
printCaller("- out ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ implements OnGatewayConnection, OnGatewayDisconnect
|
||||
console.log('- socket connected :', socket.id, socket.handshake.query.username);
|
||||
socket.username = socket.handshake.query.username.toString();
|
||||
this.sockets.set(socket.username, socket);
|
||||
|
||||
let not_emit: string = `${socket.username}_not_emit`;
|
||||
socket.join(not_emit);
|
||||
}
|
||||
async handleDisconnect(socket: socketDto) {
|
||||
this.sockets.delete(socket.username);
|
||||
|
||||
@@ -561,7 +561,7 @@ export class ChatService {
|
||||
socket.join(room_name);
|
||||
socket.room = room_name;
|
||||
let message = `${socket.username} joined the room`;
|
||||
await socket.to(socket.room).emit('message', "SERVER", message);
|
||||
await socket.to(socket.room).except(`${socket.username}_not_emit`).emit('message', "SERVER", message);
|
||||
await this.addMessageToRoom(room_name, "SERVER", message);
|
||||
|
||||
printCaller("-- out ");
|
||||
|
||||
Reference in New Issue
Block a user