diff --git a/back/volume/src/chat/chat.gateway.ts b/back/volume/src/chat/chat.gateway.ts index 8ce295d..f1263cc 100644 --- a/back/volume/src/chat/chat.gateway.ts +++ b/back/volume/src/chat/chat.gateway.ts @@ -13,13 +13,11 @@ import { ChatService } from './chat.service' import type Message from './entity/message.entity' import * as bcrypt from 'bcrypt' import { MessageService } from './message.service' -import { type User } from 'src/users/entity/user.entity' import { CreateMessageDto } from './dto/create-message.dto' import { InjectRepository } from '@nestjs/typeorm' import { Repository } from 'typeorm' import ConnectedUser from './entity/connection.entity' import { ConnectionDto } from './dto/connection.dto' -import { plainToClass } from 'class-transformer' @WebSocketGateway({ cors: { origin: /^(http|ws):\/\/localhost(:\d+)?$/ } @@ -38,7 +36,11 @@ export class ChatGateway implements OnGatewayConnection, OnGatewayDisconnect { async handleConnection (socket: Socket): Promise {} - handleDisconnect (socket: Socket): void { + async handleDisconnect (socket: Socket): Promise { + const user = await this.connectedUserRepository.findOneBy({ + socket: socket.id + }) + if (user !== null) await this.connectedUserRepository.remove(user) socket.disconnect() } diff --git a/back/volume/src/users/entity/user.entity.ts b/back/volume/src/users/entity/user.entity.ts index e9cb7db..d1fda87 100644 --- a/back/volume/src/users/entity/user.entity.ts +++ b/back/volume/src/users/entity/user.entity.ts @@ -1,4 +1,3 @@ -import { Entity, PrimaryGeneratedColumn, Column,