mirror of
https://github.com/immich-app/immich.git
synced 2025-12-18 01:11:07 +03:00
* feat: hide faces * fix: types * pr feedback * fix: svelte checks * feat: new server endpoint * refactor: rename person count dto * fix(server): linter * fix: remove duplicate button * docs: add comments * pr feedback * fix: get unhidden faces * fix: do not use PersonCountResponseDto * fix: transition * pr feedback * pr feedback * fix: remove unused check * add server tests * rename persons to people * feat: add exit button * pr feedback * add server tests * pr feedback * pr feedback * fix: show & hide faces * simplify * fix: close button * pr feeback * pr feeback --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
87 lines
2.9 KiB
TypeScript
87 lines
2.9 KiB
TypeScript
import { AssetEntity, AssetType } from '@app/infra/entities';
|
|
import { ApiProperty } from '@nestjs/swagger';
|
|
import { mapFace, PersonResponseDto } from '../../person/person.dto';
|
|
import { mapTag, TagResponseDto } from '../../tag';
|
|
import { ExifResponseDto, mapExif } from './exif-response.dto';
|
|
import { mapSmartInfo, SmartInfoResponseDto } from './smart-info-response.dto';
|
|
|
|
export class AssetResponseDto {
|
|
id!: string;
|
|
deviceAssetId!: string;
|
|
ownerId!: string;
|
|
deviceId!: string;
|
|
|
|
@ApiProperty({ enumName: 'AssetTypeEnum', enum: AssetType })
|
|
type!: AssetType;
|
|
originalPath!: string;
|
|
originalFileName!: string;
|
|
resized!: boolean;
|
|
/**base64 encoded thumbhash */
|
|
thumbhash!: string | null;
|
|
fileCreatedAt!: Date;
|
|
fileModifiedAt!: Date;
|
|
updatedAt!: Date;
|
|
isFavorite!: boolean;
|
|
isArchived!: boolean;
|
|
duration!: string;
|
|
exifInfo?: ExifResponseDto;
|
|
smartInfo?: SmartInfoResponseDto;
|
|
livePhotoVideoId?: string | null;
|
|
tags?: TagResponseDto[];
|
|
people?: PersonResponseDto[];
|
|
/**base64 encoded sha1 hash */
|
|
checksum!: string;
|
|
}
|
|
|
|
export function mapAsset(entity: AssetEntity): AssetResponseDto {
|
|
return {
|
|
id: entity.id,
|
|
deviceAssetId: entity.deviceAssetId,
|
|
ownerId: entity.ownerId,
|
|
deviceId: entity.deviceId,
|
|
type: entity.type,
|
|
originalPath: entity.originalPath,
|
|
originalFileName: entity.originalFileName,
|
|
resized: !!entity.resizePath,
|
|
thumbhash: entity.thumbhash?.toString('base64') ?? null,
|
|
fileCreatedAt: entity.fileCreatedAt,
|
|
fileModifiedAt: entity.fileModifiedAt,
|
|
updatedAt: entity.updatedAt,
|
|
isFavorite: entity.isFavorite,
|
|
isArchived: entity.isArchived,
|
|
duration: entity.duration ?? '0:00:00.00000',
|
|
exifInfo: entity.exifInfo ? mapExif(entity.exifInfo) : undefined,
|
|
smartInfo: entity.smartInfo ? mapSmartInfo(entity.smartInfo) : undefined,
|
|
livePhotoVideoId: entity.livePhotoVideoId,
|
|
tags: entity.tags?.map(mapTag),
|
|
people: entity.faces?.map(mapFace).filter((person) => !person.isHidden),
|
|
checksum: entity.checksum.toString('base64'),
|
|
};
|
|
}
|
|
|
|
export function mapAssetWithoutExif(entity: AssetEntity): AssetResponseDto {
|
|
return {
|
|
id: entity.id,
|
|
deviceAssetId: entity.deviceAssetId,
|
|
ownerId: entity.ownerId,
|
|
deviceId: entity.deviceId,
|
|
type: entity.type,
|
|
originalPath: entity.originalPath,
|
|
originalFileName: entity.originalFileName,
|
|
resized: !!entity.resizePath,
|
|
thumbhash: entity.thumbhash?.toString('base64') || null,
|
|
fileCreatedAt: entity.fileCreatedAt,
|
|
fileModifiedAt: entity.fileModifiedAt,
|
|
updatedAt: entity.updatedAt,
|
|
isFavorite: entity.isFavorite,
|
|
isArchived: entity.isArchived,
|
|
duration: entity.duration ?? '0:00:00.00000',
|
|
exifInfo: undefined,
|
|
smartInfo: entity.smartInfo ? mapSmartInfo(entity.smartInfo) : undefined,
|
|
livePhotoVideoId: entity.livePhotoVideoId,
|
|
tags: entity.tags?.map(mapTag),
|
|
people: entity.faces?.map(mapFace),
|
|
checksum: entity.checksum.toString('base64'),
|
|
};
|
|
}
|