From 6050b7fed4151c15e46aac901a311ccd79cdbe75 Mon Sep 17 00:00:00 2001 From: Paul Paffe Date: Thu, 6 Jul 2023 15:28:43 -0400 Subject: [PATCH] remove unecesarry changes --- server/src/domain/user/user.core.ts | 11 ++--------- server/src/domain/user/user.service.ts | 13 ++----------- server/src/immich/controllers/user.controller.ts | 1 - server/src/infra/entities/user.entity.ts | 3 --- 4 files changed, 4 insertions(+), 24 deletions(-) diff --git a/server/src/domain/user/user.core.ts b/server/src/domain/user/user.core.ts index 2f7b0c61fb..1b3e872256 100644 --- a/server/src/domain/user/user.core.ts +++ b/server/src/domain/user/user.core.ts @@ -116,20 +116,13 @@ export class UserCore { return createReadStream(user.profileImagePath); } - async getUserProfileImageHash(user: UserEntity): Promise { - if (!user.profileImageHash) { - throw new NotFoundException('User does not have a profile image'); - } - return user.profileImageHash; - } - async getList(filter?: UserListFilter): Promise { return this.userRepository.getList(filter); } - async createProfileImage(authUser: AuthUserDto, filePath: string, hash: string): Promise { + async createProfileImage(authUser: AuthUserDto, filePath: string): Promise { try { - return this.userRepository.update(authUser.id, { profileImagePath: filePath, profileImageHash: hash }); + return this.userRepository.update(authUser.id, { profileImagePath: filePath }); } catch (e) { Logger.error(e, 'Create User Profile Image'); throw new InternalServerErrorException('Failed to create new user profile image'); diff --git a/server/src/domain/user/user.service.ts b/server/src/domain/user/user.service.ts index 723bfdfdc5..d668151957 100644 --- a/server/src/domain/user/user.service.ts +++ b/server/src/domain/user/user.service.ts @@ -1,6 +1,6 @@ import { UserEntity } from '@app/infra/entities'; import { BadRequestException, Inject, Injectable, Logger, NotFoundException } from '@nestjs/common'; -import { createHash, randomBytes } from 'crypto'; +import { randomBytes } from 'crypto'; import { ReadStream } from 'fs'; import { IAlbumRepository } from '../album/album.repository'; import { IAssetRepository } from '../asset/asset.repository'; @@ -108,8 +108,7 @@ export class UserService { authUser: AuthUserDto, fileInfo: Express.Multer.File, ): Promise { - const hash = createHash('md5').update(fileInfo.buffer).digest('hex'); - const updatedUser = await this.userCore.createProfileImage(authUser, fileInfo.path, hash); + const updatedUser = await this.userCore.createProfileImage(authUser, fileInfo.path); return mapCreateProfileImageResponse(updatedUser.id, updatedUser.profileImagePath); } @@ -121,14 +120,6 @@ export class UserService { return this.userCore.getUserProfileImage(user); } - async getUserProfileImageHash(userId: string): Promise { - const user = await this.userCore.get(userId); - if (!user) { - throw new NotFoundException('User not found'); - } - return this.userCore.getUserProfileImageHash(user); - } - async resetAdminPassword(ask: (admin: UserResponseDto) => Promise) { const admin = await this.userCore.getAdmin(); if (!admin) { diff --git a/server/src/immich/controllers/user.controller.ts b/server/src/immich/controllers/user.controller.ts index 9c3b9cdeaa..469d89a010 100644 --- a/server/src/immich/controllers/user.controller.ts +++ b/server/src/immich/controllers/user.controller.ts @@ -102,7 +102,6 @@ export class UserController { async getProfileImage(@Param() { userId }: UserIdDto, @Response({ passthrough: true }) res: Res): Promise { const readableStream = await this.service.getUserProfileImage(userId); res.header('Content-Type', 'image/jpeg'); - res.header('ETag', await this.service.getUserProfileImageHash(userId)); return new StreamableFile(readableStream); } } diff --git a/server/src/infra/entities/user.entity.ts b/server/src/infra/entities/user.entity.ts index 495b279609..7cdac1f824 100644 --- a/server/src/infra/entities/user.entity.ts +++ b/server/src/infra/entities/user.entity.ts @@ -42,9 +42,6 @@ export class UserEntity { @Column({ default: '' }) profileImagePath!: string; - @Column({ default: '' }) - profileImageHash!: string; - @Column({ default: true }) shouldChangePassword!: boolean;