Browse Source

get channel/:id/users

master
Pheuw1 2 years ago
parent
commit
4036c70b8e
  1. 8
      back/volume/src/chat/chat.gateway.ts
  2. 1
      back/volume/src/users/entity/user.entity.ts

8
back/volume/src/chat/chat.gateway.ts

@ -13,13 +13,11 @@ import { ChatService } from './chat.service'
import type Message from './entity/message.entity' import type Message from './entity/message.entity'
import * as bcrypt from 'bcrypt' import * as bcrypt from 'bcrypt'
import { MessageService } from './message.service' import { MessageService } from './message.service'
import { type User } from 'src/users/entity/user.entity'
import { CreateMessageDto } from './dto/create-message.dto' import { CreateMessageDto } from './dto/create-message.dto'
import { InjectRepository } from '@nestjs/typeorm' import { InjectRepository } from '@nestjs/typeorm'
import { Repository } from 'typeorm' import { Repository } from 'typeorm'
import ConnectedUser from './entity/connection.entity' import ConnectedUser from './entity/connection.entity'
import { ConnectionDto } from './dto/connection.dto' import { ConnectionDto } from './dto/connection.dto'
import { plainToClass } from 'class-transformer'
@WebSocketGateway({ @WebSocketGateway({
cors: { origin: /^(http|ws):\/\/localhost(:\d+)?$/ } cors: { origin: /^(http|ws):\/\/localhost(:\d+)?$/ }
@ -38,7 +36,11 @@ export class ChatGateway implements OnGatewayConnection, OnGatewayDisconnect {
async handleConnection (socket: Socket): Promise<void> {} async handleConnection (socket: Socket): Promise<void> {}
handleDisconnect (socket: Socket): void { async handleDisconnect (socket: Socket): Promise<void> {
const user = await this.connectedUserRepository.findOneBy({
socket: socket.id
})
if (user !== null) await this.connectedUserRepository.remove(user)
socket.disconnect() socket.disconnect()
} }

1
back/volume/src/users/entity/user.entity.ts

@ -1,4 +1,3 @@
import {
Entity, Entity,
PrimaryGeneratedColumn, PrimaryGeneratedColumn,
Column, Column,

Loading…
Cancel
Save