mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
refactor(server): user core (#4722)
This commit is contained in:
@@ -1,17 +1,9 @@
|
||||
import { LibraryType, UserEntity } from '@app/infra/entities';
|
||||
import {
|
||||
BadRequestException,
|
||||
ForbiddenException,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
import { ReadStream, constants, createReadStream } from 'fs';
|
||||
import fs from 'fs/promises';
|
||||
import { BadRequestException, ForbiddenException, InternalServerErrorException, Logger } from '@nestjs/common';
|
||||
import path from 'path';
|
||||
import sanitize from 'sanitize-filename';
|
||||
import { AuthUserDto } from '../auth';
|
||||
import { ICryptoRepository, ILibraryRepository, IUserRepository, UserListFilter } from '../repositories';
|
||||
import { ICryptoRepository, ILibraryRepository, IUserRepository } from '../repositories';
|
||||
|
||||
const SALT_ROUNDS = 10;
|
||||
|
||||
@@ -131,34 +123,6 @@ export class UserCore {
|
||||
}
|
||||
}
|
||||
|
||||
async get(userId: string, withDeleted?: boolean): Promise<UserEntity | null> {
|
||||
return this.userRepository.get(userId, withDeleted);
|
||||
}
|
||||
|
||||
async getAdmin(): Promise<UserEntity | null> {
|
||||
return this.userRepository.getAdmin();
|
||||
}
|
||||
|
||||
async getByEmail(email: string, withPassword?: boolean): Promise<UserEntity | null> {
|
||||
return this.userRepository.getByEmail(email, withPassword);
|
||||
}
|
||||
|
||||
async getByOAuthId(oauthId: string): Promise<UserEntity | null> {
|
||||
return this.userRepository.getByOAuthId(oauthId);
|
||||
}
|
||||
|
||||
async getUserProfileImage(user: UserEntity): Promise<ReadStream> {
|
||||
if (!user.profileImagePath) {
|
||||
throw new NotFoundException('User does not have a profile image');
|
||||
}
|
||||
await fs.access(user.profileImagePath, constants.R_OK);
|
||||
return createReadStream(user.profileImagePath);
|
||||
}
|
||||
|
||||
async getList(filter?: UserListFilter): Promise<UserEntity[]> {
|
||||
return this.userRepository.getList(filter);
|
||||
}
|
||||
|
||||
async createProfileImage(authUser: AuthUserDto, filePath: string): Promise<UserEntity> {
|
||||
try {
|
||||
return this.userRepository.update(authUser.id, { profileImagePath: filePath });
|
||||
|
||||
Reference in New Issue
Block a user