Skip to content

Commit

Permalink
fix: update Images error, add leave room_list
Browse files Browse the repository at this point in the history
  • Loading branch information
kyeahxx19 committed Nov 22, 2023
1 parent 504fa69 commit 3517f81
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/chat/chat.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
1 change: 1 addition & 0 deletions src/dtos/user.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];

Expand Down
2 changes: 1 addition & 1 deletion src/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 3517f81

Please sign in to comment.