martabal 1 рік тому
батько
коміт
610b03d16c
1 змінених файлів з 3 додано та 3 видалено
  1. 3 3
      server/src/domain/user/user.service.ts

+ 3 - 3
server/src/domain/user/user.service.ts

@@ -93,10 +93,10 @@ export class UserService {
     authUser: AuthUserDto,
     fileInfo: Express.Multer.File,
   ): Promise<CreateProfileImageResponseDto> {
-    const user = await this.findOrFail(authUser.id, { withDeleted: false });
+    const { profileImagePath: oldpath } = await this.findOrFail(authUser.id, { withDeleted: false });
     const updatedUser = await this.userRepository.update(authUser.id, { profileImagePath: fileInfo.path });
-    if (user.profileImagePath !== '') {
-      const files = [user.profileImagePath];
+    if (oldpath !== '') {
+      const files = [oldpath];
       await this.jobRepository.queue({ name: JobName.DELETE_FILES, data: { files } });
     }
     return mapCreateProfileImageResponse(updatedUser.id, updatedUser.profileImagePath);