diff --git a/src/chat/chat.gateway.ts b/src/chat/chat.gateway.ts index 5617e72..7ef020f 100644 --- a/src/chat/chat.gateway.ts +++ b/src/chat/chat.gateway.ts @@ -147,6 +147,7 @@ export class ChatGateway @MessageBody() roomId: string, ) { this.chatService.leaveChatRoom(client.data.userId, roomId); + client.leave(`${roomId}_list`); await this.server .to(roomId) .emit('leave_room', { roomId: roomId, userId: client.data.userId }); diff --git a/src/dtos/user.dto.ts b/src/dtos/user.dto.ts index 6befd80..efdf9ca 100644 --- a/src/dtos/user.dto.ts +++ b/src/dtos/user.dto.ts @@ -146,6 +146,7 @@ export class UserProfileDto extends PickType(CreateUserDto, [ @ValidateIf((o) => o.images !== undefined && o.images !== null) @IsArray({ message: 'not valid' }) + @IsString({ each: true }) @ApiProperty({ example: ['s3.asfsva', 'asdfasdf'] }) images: string[]; diff --git a/src/user/user.controller.ts b/src/user/user.controller.ts index eece54c..3dcaa55 100644 --- a/src/user/user.controller.ts +++ b/src/user/user.controller.ts @@ -100,7 +100,7 @@ export class UserController { if (key != 'images') { this.userService.updateUserInfo(id, key, updateProfileDto[key]); } else { - this.userService.updateUserImages(id, updateProfileDto[key]); + this.userService.updateUserImages(id, updateProfileDto.images); } } return res.sendStatus(201); diff --git a/src/user/user.service.ts b/src/user/user.service.ts index a3b645c..b046f7d 100644 --- a/src/user/user.service.ts +++ b/src/user/user.service.ts @@ -82,6 +82,8 @@ export class UserService { } async updateUserImages(userId: number, images: string[]) { + if (images.length < 1) return; + await this.userImageRepository.delete({ user: { id: userId } }); const entities = images.map((image, i) => this.userImageRepository.create({