mirror of
https://github.com/KevinMidboe/immich.git
synced 2026-01-06 01:05:49 +00:00
* refactor(server): shared links * chore: tests * fix: bugs and tests * fix: missed one expired at * fix: standardize file upload checks * test: lower flutter version Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
63 lines
1.8 KiB
TypeScript
63 lines
1.8 KiB
TypeScript
import { AlbumEntity } from '@app/infra/db/entities';
|
|
import { ApiProperty } from '@nestjs/swagger';
|
|
import { AssetResponseDto, mapAsset } from '../../asset';
|
|
import { mapUser, UserResponseDto } from '../../user';
|
|
|
|
export class AlbumResponseDto {
|
|
id!: string;
|
|
ownerId!: string;
|
|
albumName!: string;
|
|
createdAt!: string;
|
|
albumThumbnailAssetId!: string | null;
|
|
shared!: boolean;
|
|
sharedUsers!: UserResponseDto[];
|
|
assets!: AssetResponseDto[];
|
|
|
|
@ApiProperty({ type: 'integer' })
|
|
assetCount!: number;
|
|
}
|
|
|
|
export function mapAlbum(entity: AlbumEntity): AlbumResponseDto {
|
|
const sharedUsers: UserResponseDto[] = [];
|
|
|
|
entity.sharedUsers?.forEach((userAlbum) => {
|
|
if (userAlbum.userInfo) {
|
|
const user = mapUser(userAlbum.userInfo);
|
|
sharedUsers.push(user);
|
|
}
|
|
});
|
|
return {
|
|
albumName: entity.albumName,
|
|
albumThumbnailAssetId: entity.albumThumbnailAssetId,
|
|
createdAt: entity.createdAt,
|
|
id: entity.id,
|
|
ownerId: entity.ownerId,
|
|
sharedUsers,
|
|
shared: sharedUsers.length > 0 || entity.sharedLinks?.length > 0,
|
|
assets: entity.assets?.map((assetAlbum) => mapAsset(assetAlbum.assetInfo)) || [],
|
|
assetCount: entity.assets?.length || 0,
|
|
};
|
|
}
|
|
|
|
export function mapAlbumExcludeAssetInfo(entity: AlbumEntity): AlbumResponseDto {
|
|
const sharedUsers: UserResponseDto[] = [];
|
|
|
|
entity.sharedUsers?.forEach((userAlbum) => {
|
|
if (userAlbum.userInfo) {
|
|
const user = mapUser(userAlbum.userInfo);
|
|
sharedUsers.push(user);
|
|
}
|
|
});
|
|
return {
|
|
albumName: entity.albumName,
|
|
albumThumbnailAssetId: entity.albumThumbnailAssetId,
|
|
createdAt: entity.createdAt,
|
|
id: entity.id,
|
|
ownerId: entity.ownerId,
|
|
sharedUsers,
|
|
shared: sharedUsers.length > 0 || entity.sharedLinks?.length > 0,
|
|
assets: [],
|
|
assetCount: entity.assets?.length || 0,
|
|
};
|
|
}
|