mirror of
https://github.com/immich-app/immich.git
synced 2025-12-20 01:11:46 +03:00
chore(server): remove user count endpoint (#4724)
* chore: remove unused endpoint * chore: open api
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
export * from './create-profile-image.dto';
|
||||
export * from './create-user.dto';
|
||||
export * from './update-user.dto';
|
||||
export * from './user-count.dto';
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsBoolean } from 'class-validator';
|
||||
import { Optional } from '../../domain.util';
|
||||
|
||||
export class UserCountDto {
|
||||
@IsBoolean()
|
||||
@Optional()
|
||||
@Transform(({ value }) => value === 'true')
|
||||
/**
|
||||
* When true, return the number of admins accounts
|
||||
*/
|
||||
admin?: boolean = false;
|
||||
}
|
||||
@@ -1,3 +1,2 @@
|
||||
export * from './create-profile-image-response.dto';
|
||||
export * from './user-count-response.dto';
|
||||
export * from './user-response.dto';
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class UserCountResponseDto {
|
||||
@ApiProperty({ type: 'integer' })
|
||||
userCount!: number;
|
||||
}
|
||||
|
||||
export function mapUserCountResponse(count: number): UserCountResponseDto {
|
||||
return {
|
||||
userCount: count,
|
||||
};
|
||||
}
|
||||
@@ -220,24 +220,6 @@ describe(UserService.name, () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('getCount', () => {
|
||||
it('should get the user count', async () => {
|
||||
userMock.getList.mockResolvedValue([adminUser]);
|
||||
|
||||
const response = await sut.getCount({});
|
||||
|
||||
expect(userMock.getList).toHaveBeenCalled();
|
||||
expect(response).toEqual({ userCount: 1 });
|
||||
});
|
||||
|
||||
it('should get the user count of all admin users', async () => {
|
||||
userMock.getList.mockResolvedValue([adminUser, immichUser]);
|
||||
|
||||
await expect(sut.getCount({ admin: true })).resolves.toEqual({ userCount: 1 });
|
||||
expect(userMock.getList).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('update', () => {
|
||||
it('should update user', async () => {
|
||||
const update: UpdateUserDto = {
|
||||
|
||||
@@ -14,15 +14,8 @@ import {
|
||||
IUserRepository,
|
||||
} from '../repositories';
|
||||
import { StorageCore, StorageFolder } from '../storage';
|
||||
import { CreateUserDto, UpdateUserDto, UserCountDto } from './dto';
|
||||
import {
|
||||
CreateProfileImageResponseDto,
|
||||
UserCountResponseDto,
|
||||
UserResponseDto,
|
||||
mapCreateProfileImageResponse,
|
||||
mapUser,
|
||||
mapUserCountResponse,
|
||||
} from './response-dto';
|
||||
import { CreateUserDto, UpdateUserDto } from './dto';
|
||||
import { CreateProfileImageResponseDto, UserResponseDto, mapCreateProfileImageResponse, mapUser } from './response-dto';
|
||||
import { UserCore } from './user.core';
|
||||
|
||||
@Injectable()
|
||||
@@ -64,16 +57,6 @@ export class UserService {
|
||||
return mapUser(user);
|
||||
}
|
||||
|
||||
async getCount(dto: UserCountDto): Promise<UserCountResponseDto> {
|
||||
let users = await this.userCore.getList();
|
||||
|
||||
if (dto.admin) {
|
||||
users = users.filter((user) => user.isAdmin);
|
||||
}
|
||||
|
||||
return mapUserCountResponse(users.length);
|
||||
}
|
||||
|
||||
async create(createUserDto: CreateUserDto): Promise<UserResponseDto> {
|
||||
const createdUser = await this.userCore.createUser(createUserDto);
|
||||
return mapUser(createdUser);
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import {
|
||||
AuthUserDto,
|
||||
UserCountDto as CountDto,
|
||||
CreateUserDto as CreateDto,
|
||||
CreateProfileImageDto,
|
||||
CreateProfileImageResponseDto,
|
||||
UpdateUserDto as UpdateDto,
|
||||
UserCountResponseDto,
|
||||
UserResponseDto,
|
||||
UserService,
|
||||
} from '@app/domain';
|
||||
@@ -59,12 +57,6 @@ export class UserController {
|
||||
return this.service.create(createUserDto);
|
||||
}
|
||||
|
||||
@AdminRoute()
|
||||
@Get('count')
|
||||
getUserCount(@Query() dto: CountDto): Promise<UserCountResponseDto> {
|
||||
return this.service.getCount(dto);
|
||||
}
|
||||
|
||||
@AdminRoute()
|
||||
@Delete(':id')
|
||||
deleteUser(@AuthUser() authUser: AuthUserDto, @Param() { id }: UUIDParamDto): Promise<UserResponseDto> {
|
||||
|
||||
Reference in New Issue
Block a user