mirror of
https://github.com/immich-app/immich.git
synced 2025-12-18 17:23:16 +03:00
* feat: unassign person faces * multiple improvements * chore: regenerate api * feat: improve face interactions in photos * fix: tests * fix: tests * optimize * fix: wrong assignment on complex-multiple re-assignments * fix: thumbnails with large photos * fix: complex reassign * fix: don't send people with faces * fix: person thumbnail generation * chore: regenerate api * add tess * feat: face box even when zoomed * fix: change feature photo * feat: make the blue icon hoverable * chore: regenerate api * feat: use websocket * fix: loading spinner when clicking on the done button * fix: use the svelte way * fix: tests * simplify * fix: unused vars * fix: remove unused code * fix: add migration * chore: regenerate api * ci: add unit tests * chore: regenerate api * feat: if a new person is created for a face and the server takes more than 15 seconds to generate the person thumbnail, don't wait for it * reorganize * chore: regenerate api * feat: global edit * pr feedback * pr feedback * simplify * revert test * fix: face generation * fix: tests * fix: face generation * fix merge * feat: search names in unmerge face selector modal * fix: merge face selector * simplify feature photo generation * fix: change endpoint * pr feedback * chore: fix merge * chore: fix merge * fix: tests * fix: edit & hide buttons * fix: tests * feat: show if person is hidden * feat: rename face to person * feat: split in new panel * copy-paste-error * pr feedback * fix: feature photo * do not leak faces * fix: unmerge modal * fix: merge modal event * feat(server): remove duplicates * fix: title for image thumbnails * fix: disable side panel when there's no face until next PR --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
103 lines
2.9 KiB
TypeScript
103 lines
2.9 KiB
TypeScript
import {
|
|
AssetFaceUpdateDto,
|
|
AssetResponseDto,
|
|
AuthUserDto,
|
|
BulkIdResponseDto,
|
|
ImmichReadStream,
|
|
MergePersonDto,
|
|
PeopleResponseDto,
|
|
PeopleUpdateDto,
|
|
PersonResponseDto,
|
|
PersonSearchDto,
|
|
PersonService,
|
|
PersonStatisticsResponseDto,
|
|
PersonUpdateDto,
|
|
} from '@app/domain';
|
|
import { Body, Controller, Get, Param, Post, Put, Query, StreamableFile } from '@nestjs/common';
|
|
import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
|
import { AuthUser, Authenticated } from '../app.guard';
|
|
import { UseValidation } from '../app.utils';
|
|
import { UUIDParamDto } from './dto/uuid-param.dto';
|
|
|
|
function asStreamableFile({ stream, type, length }: ImmichReadStream) {
|
|
return new StreamableFile(stream, { type, length });
|
|
}
|
|
|
|
@ApiTags('Person')
|
|
@Controller('person')
|
|
@Authenticated()
|
|
@UseValidation()
|
|
export class PersonController {
|
|
constructor(private service: PersonService) {}
|
|
|
|
@Get()
|
|
getAllPeople(@AuthUser() authUser: AuthUserDto, @Query() withHidden: PersonSearchDto): Promise<PeopleResponseDto> {
|
|
return this.service.getAll(authUser, withHidden);
|
|
}
|
|
|
|
@Post()
|
|
createPerson(@AuthUser() authUser: AuthUserDto): Promise<PersonResponseDto> {
|
|
return this.service.createPerson(authUser);
|
|
}
|
|
|
|
@Put(':id/reassign')
|
|
reassignFaces(
|
|
@AuthUser() authUser: AuthUserDto,
|
|
@Param() { id }: UUIDParamDto,
|
|
@Body() dto: AssetFaceUpdateDto,
|
|
): Promise<PersonResponseDto[]> {
|
|
return this.service.reassignFaces(authUser, id, dto);
|
|
}
|
|
|
|
@Put()
|
|
updatePeople(@AuthUser() authUser: AuthUserDto, @Body() dto: PeopleUpdateDto): Promise<BulkIdResponseDto[]> {
|
|
return this.service.updatePeople(authUser, dto);
|
|
}
|
|
|
|
@Get(':id')
|
|
getPerson(@AuthUser() authUser: AuthUserDto, @Param() { id }: UUIDParamDto): Promise<PersonResponseDto> {
|
|
return this.service.getById(authUser, id);
|
|
}
|
|
|
|
@Put(':id')
|
|
updatePerson(
|
|
@AuthUser() authUser: AuthUserDto,
|
|
@Param() { id }: UUIDParamDto,
|
|
@Body() dto: PersonUpdateDto,
|
|
): Promise<PersonResponseDto> {
|
|
return this.service.update(authUser, id, dto);
|
|
}
|
|
|
|
@Get(':id/statistics')
|
|
getPersonStatistics(
|
|
@AuthUser() authUser: AuthUserDto,
|
|
@Param() { id }: UUIDParamDto,
|
|
): Promise<PersonStatisticsResponseDto> {
|
|
return this.service.getStatistics(authUser, id);
|
|
}
|
|
|
|
@Get(':id/thumbnail')
|
|
@ApiOkResponse({
|
|
content: {
|
|
'image/jpeg': { schema: { type: 'string', format: 'binary' } },
|
|
},
|
|
})
|
|
getPersonThumbnail(@AuthUser() authUser: AuthUserDto, @Param() { id }: UUIDParamDto) {
|
|
return this.service.getThumbnail(authUser, id).then(asStreamableFile);
|
|
}
|
|
|
|
@Get(':id/assets')
|
|
getPersonAssets(@AuthUser() authUser: AuthUserDto, @Param() { id }: UUIDParamDto): Promise<AssetResponseDto[]> {
|
|
return this.service.getAssets(authUser, id);
|
|
}
|
|
|
|
@Post(':id/merge')
|
|
mergePerson(
|
|
@AuthUser() authUser: AuthUserDto,
|
|
@Param() { id }: UUIDParamDto,
|
|
@Body() dto: MergePersonDto,
|
|
): Promise<BulkIdResponseDto[]> {
|
|
return this.service.mergePerson(authUser, id, dto);
|
|
}
|
|
}
|