2023-05-25 04:10:45 +02:00
|
|
|
import { AlbumEntity, AssetEntity, UserEntity } from '@app/infra/entities';
|
2023-06-28 15:56:24 +02:00
|
|
|
import { BadRequestException, Inject, Injectable } from '@nestjs/common';
|
2023-10-09 16:25:03 +02:00
|
|
|
import { AccessCore, Permission } from '../access';
|
|
|
|
import { BulkIdErrorReason, BulkIdResponseDto, BulkIdsDto } from '../asset';
|
2023-03-26 04:46:48 +02:00
|
|
|
import { AuthUserDto } from '../auth';
|
2023-10-09 16:25:03 +02:00
|
|
|
import { JobName } from '../job';
|
|
|
|
import {
|
|
|
|
AlbumInfoOptions,
|
|
|
|
IAccessRepository,
|
|
|
|
IAlbumRepository,
|
|
|
|
IAssetRepository,
|
|
|
|
IJobRepository,
|
|
|
|
IUserRepository,
|
|
|
|
} from '../repositories';
|
2023-08-11 18:00:51 +02:00
|
|
|
import {
|
|
|
|
AlbumCountResponseDto,
|
|
|
|
AlbumResponseDto,
|
|
|
|
mapAlbum,
|
|
|
|
mapAlbumWithAssets,
|
|
|
|
mapAlbumWithoutAssets,
|
|
|
|
} from './album-response.dto';
|
|
|
|
import { AddUsersDto, AlbumInfoDto, CreateAlbumDto, GetAlbumsDto, UpdateAlbumDto } from './dto';
|
2023-03-26 04:46:48 +02:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class AlbumService {
|
2023-06-28 15:56:24 +02:00
|
|
|
private access: AccessCore;
|
2023-03-26 04:46:48 +02:00
|
|
|
constructor(
|
2023-06-28 15:56:24 +02:00
|
|
|
@Inject(IAccessRepository) accessRepository: IAccessRepository,
|
2023-03-26 04:46:48 +02:00
|
|
|
@Inject(IAlbumRepository) private albumRepository: IAlbumRepository,
|
|
|
|
@Inject(IAssetRepository) private assetRepository: IAssetRepository,
|
2023-05-25 04:10:45 +02:00
|
|
|
@Inject(IJobRepository) private jobRepository: IJobRepository,
|
2023-06-07 16:37:25 +02:00
|
|
|
@Inject(IUserRepository) private userRepository: IUserRepository,
|
2023-06-28 15:56:24 +02:00
|
|
|
) {
|
2023-10-23 14:37:51 +02:00
|
|
|
this.access = AccessCore.create(accessRepository);
|
2023-06-28 15:56:24 +02:00
|
|
|
}
|
2023-03-26 04:46:48 +02:00
|
|
|
|
2023-06-16 17:48:48 +02:00
|
|
|
async getCount(authUser: AuthUserDto): Promise<AlbumCountResponseDto> {
|
|
|
|
const [owned, shared, notShared] = await Promise.all([
|
|
|
|
this.albumRepository.getOwned(authUser.id),
|
|
|
|
this.albumRepository.getShared(authUser.id),
|
|
|
|
this.albumRepository.getNotShared(authUser.id),
|
|
|
|
]);
|
|
|
|
|
|
|
|
return {
|
|
|
|
owned: owned.length,
|
|
|
|
shared: shared.length,
|
|
|
|
notShared: notShared.length,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-05-25 04:10:45 +02:00
|
|
|
async getAll({ id: ownerId }: AuthUserDto, { assetId, shared }: GetAlbumsDto): Promise<AlbumResponseDto[]> {
|
2023-08-02 03:29:14 +02:00
|
|
|
const invalidAlbumIds = await this.albumRepository.getInvalidThumbnail();
|
|
|
|
for (const albumId of invalidAlbumIds) {
|
|
|
|
const newThumbnail = await this.assetRepository.getFirstAssetForAlbumId(albumId);
|
|
|
|
await this.albumRepository.update({ id: albumId, albumThumbnailAsset: newThumbnail });
|
|
|
|
}
|
2023-03-26 04:46:48 +02:00
|
|
|
|
|
|
|
let albums: AlbumEntity[];
|
|
|
|
if (assetId) {
|
|
|
|
albums = await this.albumRepository.getByAssetId(ownerId, assetId);
|
|
|
|
} else if (shared === true) {
|
|
|
|
albums = await this.albumRepository.getShared(ownerId);
|
|
|
|
} else if (shared === false) {
|
|
|
|
albums = await this.albumRepository.getNotShared(ownerId);
|
|
|
|
} else {
|
|
|
|
albums = await this.albumRepository.getOwned(ownerId);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get asset count for each album. Then map the result to an object:
|
|
|
|
// { [albumId]: assetCount }
|
|
|
|
const albumsAssetCount = await this.albumRepository.getAssetCountForIds(albums.map((album) => album.id));
|
|
|
|
const albumsAssetCountObj = albumsAssetCount.reduce((obj: Record<string, number>, { albumId, assetCount }) => {
|
|
|
|
obj[albumId] = assetCount;
|
|
|
|
return obj;
|
|
|
|
}, {});
|
|
|
|
|
2023-06-21 03:00:59 +02:00
|
|
|
return Promise.all(
|
|
|
|
albums.map(async (album) => {
|
|
|
|
const lastModifiedAsset = await this.assetRepository.getLastUpdatedAssetForAlbumId(album.id);
|
|
|
|
return {
|
2023-08-11 18:00:51 +02:00
|
|
|
...mapAlbumWithoutAssets(album),
|
|
|
|
sharedLinks: undefined,
|
2023-06-21 03:00:59 +02:00
|
|
|
assetCount: albumsAssetCountObj[album.id],
|
|
|
|
lastModifiedAssetTimestamp: lastModifiedAsset?.fileModifiedAt,
|
2023-08-11 18:00:51 +02:00
|
|
|
};
|
2023-06-21 03:00:59 +02:00
|
|
|
}),
|
|
|
|
);
|
2023-03-26 04:46:48 +02:00
|
|
|
}
|
|
|
|
|
2023-08-11 18:00:51 +02:00
|
|
|
async get(authUser: AuthUserDto, id: string, dto: AlbumInfoDto) {
|
2023-08-02 03:29:14 +02:00
|
|
|
await this.access.requirePermission(authUser, Permission.ALBUM_READ, id);
|
|
|
|
await this.albumRepository.updateThumbnails();
|
2023-08-15 20:34:02 +02:00
|
|
|
return mapAlbum(await this.findOrFail(id, { withAssets: true }), !dto.withoutAssets);
|
2023-03-26 04:46:48 +02:00
|
|
|
}
|
2023-05-25 04:10:45 +02:00
|
|
|
|
|
|
|
async create(authUser: AuthUserDto, dto: CreateAlbumDto): Promise<AlbumResponseDto> {
|
2023-06-07 16:37:25 +02:00
|
|
|
for (const userId of dto.sharedWithUserIds || []) {
|
|
|
|
const exists = await this.userRepository.get(userId);
|
|
|
|
if (!exists) {
|
|
|
|
throw new BadRequestException('User not found');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-25 04:10:45 +02:00
|
|
|
const album = await this.albumRepository.create({
|
|
|
|
ownerId: authUser.id,
|
|
|
|
albumName: dto.albumName,
|
2023-08-06 04:43:26 +02:00
|
|
|
description: dto.description,
|
2023-08-28 21:41:57 +02:00
|
|
|
sharedUsers: dto.sharedWithUserIds?.map((value) => ({ id: value }) as UserEntity) ?? [],
|
|
|
|
assets: (dto.assetIds || []).map((id) => ({ id }) as AssetEntity),
|
2023-05-25 04:10:45 +02:00
|
|
|
albumThumbnailAssetId: dto.assetIds?.[0] || null,
|
|
|
|
});
|
2023-06-07 16:37:25 +02:00
|
|
|
|
2023-05-25 04:10:45 +02:00
|
|
|
await this.jobRepository.queue({ name: JobName.SEARCH_INDEX_ALBUM, data: { ids: [album.id] } });
|
2023-08-11 18:00:51 +02:00
|
|
|
return mapAlbumWithAssets(album);
|
2023-05-25 04:10:45 +02:00
|
|
|
}
|
2023-05-25 21:37:19 +02:00
|
|
|
|
|
|
|
async update(authUser: AuthUserDto, id: string, dto: UpdateAlbumDto): Promise<AlbumResponseDto> {
|
2023-06-28 15:56:24 +02:00
|
|
|
await this.access.requirePermission(authUser, Permission.ALBUM_UPDATE, id);
|
|
|
|
|
2023-08-15 20:34:02 +02:00
|
|
|
const album = await this.findOrFail(id, { withAssets: true });
|
2023-05-25 21:37:19 +02:00
|
|
|
|
|
|
|
if (dto.albumThumbnailAssetId) {
|
2023-10-18 17:56:00 +02:00
|
|
|
const valid = await this.albumRepository.hasAsset({ albumId: id, assetId: dto.albumThumbnailAssetId });
|
2023-05-25 21:37:19 +02:00
|
|
|
if (!valid) {
|
|
|
|
throw new BadRequestException('Invalid album thumbnail');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const updatedAlbum = await this.albumRepository.update({
|
|
|
|
id: album.id,
|
|
|
|
albumName: dto.albumName,
|
2023-08-06 04:43:26 +02:00
|
|
|
description: dto.description,
|
2023-05-25 21:37:19 +02:00
|
|
|
albumThumbnailAssetId: dto.albumThumbnailAssetId,
|
|
|
|
});
|
|
|
|
|
|
|
|
await this.jobRepository.queue({ name: JobName.SEARCH_INDEX_ALBUM, data: { ids: [updatedAlbum.id] } });
|
|
|
|
|
2023-08-15 20:34:02 +02:00
|
|
|
return mapAlbumWithoutAssets(updatedAlbum);
|
2023-05-25 21:37:19 +02:00
|
|
|
}
|
2023-05-26 15:04:09 +02:00
|
|
|
|
|
|
|
async delete(authUser: AuthUserDto, id: string): Promise<void> {
|
2023-06-28 15:56:24 +02:00
|
|
|
await this.access.requirePermission(authUser, Permission.ALBUM_DELETE, id);
|
|
|
|
|
2023-08-15 20:34:02 +02:00
|
|
|
const album = await this.findOrFail(id, { withAssets: false });
|
2023-05-26 15:04:09 +02:00
|
|
|
|
|
|
|
await this.albumRepository.delete(album);
|
|
|
|
await this.jobRepository.queue({ name: JobName.SEARCH_REMOVE_ALBUM, data: { ids: [id] } });
|
|
|
|
}
|
2023-06-07 16:37:25 +02:00
|
|
|
|
2023-08-02 03:29:14 +02:00
|
|
|
async addAssets(authUser: AuthUserDto, id: string, dto: BulkIdsDto): Promise<BulkIdResponseDto[]> {
|
2023-10-18 17:56:00 +02:00
|
|
|
const album = await this.findOrFail(id, { withAssets: false });
|
2023-08-02 03:29:14 +02:00
|
|
|
|
|
|
|
await this.access.requirePermission(authUser, Permission.ALBUM_READ, id);
|
|
|
|
|
fix(server): Check album asset membership in bulk (#4603)
Add `AlbumRepository` method to retrieve an album's asset ids, with an
optional parameter to only filter by the provided asset ids. With this,
we can now check asset membership using a single query.
When adding or removing assets to an album, checking whether each asset
is already present in the album now requires a single query, instead of
one query per asset.
Related to #4539 performance improvements.
Before:
```
// Asset membership and permissions check (2 queries per asset)
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "albums" "AlbumEntity" LEFT JOIN "albums_assets_assets" "AlbumEntity_AlbumEntity__AlbumEntity_assets" ON "AlbumEntity_AlbumEntity__AlbumEntity_assets"."albumsId"="AlbumEntity"."id" LEFT JOIN "assets" "AlbumEntity__AlbumEntity_assets" ON "AlbumEntity__AlbumEntity_assets"."id"="AlbumEntity_AlbumEntity__AlbumEntity_assets"."assetsId" AND ("AlbumEntity__AlbumEntity_assets"."deletedAt" IS NULL) WHERE ( ("AlbumEntity"."id" = $1 AND "AlbumEntity__AlbumEntity_assets"."id" = $2) ) AND ( "AlbumEntity"."deletedAt" IS NULL )) LIMIT 1 -- PARAMETERS: ["3fdf0e58-a1c7-4efe-8288-06e4c3f38df9","b666ae6c-afa8-4d6f-a1ad-7091a0659320"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["b666ae6c-afa8-4d6f-a1ad-7091a0659320","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "albums" "AlbumEntity" LEFT JOIN "albums_assets_assets" "AlbumEntity_AlbumEntity__AlbumEntity_assets" ON "AlbumEntity_AlbumEntity__AlbumEntity_assets"."albumsId"="AlbumEntity"."id" LEFT JOIN "assets" "AlbumEntity__AlbumEntity_assets" ON "AlbumEntity__AlbumEntity_assets"."id"="AlbumEntity_AlbumEntity__AlbumEntity_assets"."assetsId" AND ("AlbumEntity__AlbumEntity_assets"."deletedAt" IS NULL) WHERE ( ("AlbumEntity"."id" = $1 AND "AlbumEntity__AlbumEntity_assets"."id" = $2) ) AND ( "AlbumEntity"."deletedAt" IS NULL )) LIMIT 1 -- PARAMETERS: ["3fdf0e58-a1c7-4efe-8288-06e4c3f38df9","c656ab1c-7775-4ff7-b56f-01308c072a76"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["c656ab1c-7775-4ff7-b56f-01308c072a76","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "albums" "AlbumEntity" LEFT JOIN "albums_assets_assets" "AlbumEntity_AlbumEntity__AlbumEntity_assets" ON "AlbumEntity_AlbumEntity__AlbumEntity_assets"."albumsId"="AlbumEntity"."id" LEFT JOIN "assets" "AlbumEntity__AlbumEntity_assets" ON "AlbumEntity__AlbumEntity_assets"."id"="AlbumEntity_AlbumEntity__AlbumEntity_assets"."assetsId" AND ("AlbumEntity__AlbumEntity_assets"."deletedAt" IS NULL) WHERE ( ("AlbumEntity"."id" = $1 AND "AlbumEntity__AlbumEntity_assets"."id" = $2) ) AND ( "AlbumEntity"."deletedAt" IS NULL )) LIMIT 1 -- PARAMETERS: ["3fdf0e58-a1c7-4efe-8288-06e4c3f38df9","cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
```
After:
```
// Asset membership check (1 query for all assets)
immich_server | query: SELECT "albums_assets"."assetsId" AS "assetId" FROM "albums_assets_assets" "albums_assets" WHERE "albums_assets"."albumsId" = $1 AND "albums_assets"."assetsId" IN ($2, $3, $4) -- PARAMETERS: ["ca870d76-6311-4e89-bf9a-f5b51ea2452c","b666ae6c-afa8-4d6f-a1ad-7091a0659320","c656ab1c-7775-4ff7-b56f-01308c072a76","cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9"]
// Permissions check (1 query per asset)
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["b666ae6c-afa8-4d6f-a1ad-7091a0659320","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["c656ab1c-7775-4ff7-b56f-01308c072a76","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
```
2023-10-23 15:02:27 +02:00
|
|
|
const existingAssetIds = await this.albumRepository.getAssetIds(id, dto.ids);
|
|
|
|
|
2023-08-02 03:29:14 +02:00
|
|
|
const results: BulkIdResponseDto[] = [];
|
2023-10-18 17:56:00 +02:00
|
|
|
for (const assetId of dto.ids) {
|
fix(server): Check album asset membership in bulk (#4603)
Add `AlbumRepository` method to retrieve an album's asset ids, with an
optional parameter to only filter by the provided asset ids. With this,
we can now check asset membership using a single query.
When adding or removing assets to an album, checking whether each asset
is already present in the album now requires a single query, instead of
one query per asset.
Related to #4539 performance improvements.
Before:
```
// Asset membership and permissions check (2 queries per asset)
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "albums" "AlbumEntity" LEFT JOIN "albums_assets_assets" "AlbumEntity_AlbumEntity__AlbumEntity_assets" ON "AlbumEntity_AlbumEntity__AlbumEntity_assets"."albumsId"="AlbumEntity"."id" LEFT JOIN "assets" "AlbumEntity__AlbumEntity_assets" ON "AlbumEntity__AlbumEntity_assets"."id"="AlbumEntity_AlbumEntity__AlbumEntity_assets"."assetsId" AND ("AlbumEntity__AlbumEntity_assets"."deletedAt" IS NULL) WHERE ( ("AlbumEntity"."id" = $1 AND "AlbumEntity__AlbumEntity_assets"."id" = $2) ) AND ( "AlbumEntity"."deletedAt" IS NULL )) LIMIT 1 -- PARAMETERS: ["3fdf0e58-a1c7-4efe-8288-06e4c3f38df9","b666ae6c-afa8-4d6f-a1ad-7091a0659320"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["b666ae6c-afa8-4d6f-a1ad-7091a0659320","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "albums" "AlbumEntity" LEFT JOIN "albums_assets_assets" "AlbumEntity_AlbumEntity__AlbumEntity_assets" ON "AlbumEntity_AlbumEntity__AlbumEntity_assets"."albumsId"="AlbumEntity"."id" LEFT JOIN "assets" "AlbumEntity__AlbumEntity_assets" ON "AlbumEntity__AlbumEntity_assets"."id"="AlbumEntity_AlbumEntity__AlbumEntity_assets"."assetsId" AND ("AlbumEntity__AlbumEntity_assets"."deletedAt" IS NULL) WHERE ( ("AlbumEntity"."id" = $1 AND "AlbumEntity__AlbumEntity_assets"."id" = $2) ) AND ( "AlbumEntity"."deletedAt" IS NULL )) LIMIT 1 -- PARAMETERS: ["3fdf0e58-a1c7-4efe-8288-06e4c3f38df9","c656ab1c-7775-4ff7-b56f-01308c072a76"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["c656ab1c-7775-4ff7-b56f-01308c072a76","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "albums" "AlbumEntity" LEFT JOIN "albums_assets_assets" "AlbumEntity_AlbumEntity__AlbumEntity_assets" ON "AlbumEntity_AlbumEntity__AlbumEntity_assets"."albumsId"="AlbumEntity"."id" LEFT JOIN "assets" "AlbumEntity__AlbumEntity_assets" ON "AlbumEntity__AlbumEntity_assets"."id"="AlbumEntity_AlbumEntity__AlbumEntity_assets"."assetsId" AND ("AlbumEntity__AlbumEntity_assets"."deletedAt" IS NULL) WHERE ( ("AlbumEntity"."id" = $1 AND "AlbumEntity__AlbumEntity_assets"."id" = $2) ) AND ( "AlbumEntity"."deletedAt" IS NULL )) LIMIT 1 -- PARAMETERS: ["3fdf0e58-a1c7-4efe-8288-06e4c3f38df9","cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
```
After:
```
// Asset membership check (1 query for all assets)
immich_server | query: SELECT "albums_assets"."assetsId" AS "assetId" FROM "albums_assets_assets" "albums_assets" WHERE "albums_assets"."albumsId" = $1 AND "albums_assets"."assetsId" IN ($2, $3, $4) -- PARAMETERS: ["ca870d76-6311-4e89-bf9a-f5b51ea2452c","b666ae6c-afa8-4d6f-a1ad-7091a0659320","c656ab1c-7775-4ff7-b56f-01308c072a76","cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9"]
// Permissions check (1 query per asset)
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["b666ae6c-afa8-4d6f-a1ad-7091a0659320","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["c656ab1c-7775-4ff7-b56f-01308c072a76","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
```
2023-10-23 15:02:27 +02:00
|
|
|
const hasAsset = existingAssetIds.has(assetId);
|
2023-08-02 03:29:14 +02:00
|
|
|
if (hasAsset) {
|
2023-10-18 17:56:00 +02:00
|
|
|
results.push({ id: assetId, success: false, error: BulkIdErrorReason.DUPLICATE });
|
2023-08-02 03:29:14 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-10-18 17:56:00 +02:00
|
|
|
const hasAccess = await this.access.hasPermission(authUser, Permission.ASSET_SHARE, assetId);
|
2023-08-02 03:29:14 +02:00
|
|
|
if (!hasAccess) {
|
2023-10-18 17:56:00 +02:00
|
|
|
results.push({ id: assetId, success: false, error: BulkIdErrorReason.NO_PERMISSION });
|
2023-08-02 03:29:14 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-10-18 17:56:00 +02:00
|
|
|
results.push({ id: assetId, success: true });
|
2023-08-02 03:29:14 +02:00
|
|
|
}
|
|
|
|
|
2023-10-18 17:56:00 +02:00
|
|
|
const newAssetIds = results.filter(({ success }) => success).map(({ id }) => id);
|
|
|
|
if (newAssetIds.length > 0) {
|
|
|
|
await this.albumRepository.addAssets({ albumId: id, assetIds: newAssetIds });
|
2023-08-02 03:29:14 +02:00
|
|
|
await this.albumRepository.update({
|
|
|
|
id,
|
|
|
|
updatedAt: new Date(),
|
2023-10-18 17:56:00 +02:00
|
|
|
albumThumbnailAssetId: album.albumThumbnailAssetId ?? newAssetIds[0],
|
2023-08-02 03:29:14 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
|
|
|
async removeAssets(authUser: AuthUserDto, id: string, dto: BulkIdsDto): Promise<BulkIdResponseDto[]> {
|
2023-10-18 17:56:00 +02:00
|
|
|
const album = await this.findOrFail(id, { withAssets: false });
|
2023-08-02 03:29:14 +02:00
|
|
|
|
|
|
|
await this.access.requirePermission(authUser, Permission.ALBUM_READ, id);
|
|
|
|
|
fix(server): Check album asset membership in bulk (#4603)
Add `AlbumRepository` method to retrieve an album's asset ids, with an
optional parameter to only filter by the provided asset ids. With this,
we can now check asset membership using a single query.
When adding or removing assets to an album, checking whether each asset
is already present in the album now requires a single query, instead of
one query per asset.
Related to #4539 performance improvements.
Before:
```
// Asset membership and permissions check (2 queries per asset)
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "albums" "AlbumEntity" LEFT JOIN "albums_assets_assets" "AlbumEntity_AlbumEntity__AlbumEntity_assets" ON "AlbumEntity_AlbumEntity__AlbumEntity_assets"."albumsId"="AlbumEntity"."id" LEFT JOIN "assets" "AlbumEntity__AlbumEntity_assets" ON "AlbumEntity__AlbumEntity_assets"."id"="AlbumEntity_AlbumEntity__AlbumEntity_assets"."assetsId" AND ("AlbumEntity__AlbumEntity_assets"."deletedAt" IS NULL) WHERE ( ("AlbumEntity"."id" = $1 AND "AlbumEntity__AlbumEntity_assets"."id" = $2) ) AND ( "AlbumEntity"."deletedAt" IS NULL )) LIMIT 1 -- PARAMETERS: ["3fdf0e58-a1c7-4efe-8288-06e4c3f38df9","b666ae6c-afa8-4d6f-a1ad-7091a0659320"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["b666ae6c-afa8-4d6f-a1ad-7091a0659320","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "albums" "AlbumEntity" LEFT JOIN "albums_assets_assets" "AlbumEntity_AlbumEntity__AlbumEntity_assets" ON "AlbumEntity_AlbumEntity__AlbumEntity_assets"."albumsId"="AlbumEntity"."id" LEFT JOIN "assets" "AlbumEntity__AlbumEntity_assets" ON "AlbumEntity__AlbumEntity_assets"."id"="AlbumEntity_AlbumEntity__AlbumEntity_assets"."assetsId" AND ("AlbumEntity__AlbumEntity_assets"."deletedAt" IS NULL) WHERE ( ("AlbumEntity"."id" = $1 AND "AlbumEntity__AlbumEntity_assets"."id" = $2) ) AND ( "AlbumEntity"."deletedAt" IS NULL )) LIMIT 1 -- PARAMETERS: ["3fdf0e58-a1c7-4efe-8288-06e4c3f38df9","c656ab1c-7775-4ff7-b56f-01308c072a76"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["c656ab1c-7775-4ff7-b56f-01308c072a76","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "albums" "AlbumEntity" LEFT JOIN "albums_assets_assets" "AlbumEntity_AlbumEntity__AlbumEntity_assets" ON "AlbumEntity_AlbumEntity__AlbumEntity_assets"."albumsId"="AlbumEntity"."id" LEFT JOIN "assets" "AlbumEntity__AlbumEntity_assets" ON "AlbumEntity__AlbumEntity_assets"."id"="AlbumEntity_AlbumEntity__AlbumEntity_assets"."assetsId" AND ("AlbumEntity__AlbumEntity_assets"."deletedAt" IS NULL) WHERE ( ("AlbumEntity"."id" = $1 AND "AlbumEntity__AlbumEntity_assets"."id" = $2) ) AND ( "AlbumEntity"."deletedAt" IS NULL )) LIMIT 1 -- PARAMETERS: ["3fdf0e58-a1c7-4efe-8288-06e4c3f38df9","cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
```
After:
```
// Asset membership check (1 query for all assets)
immich_server | query: SELECT "albums_assets"."assetsId" AS "assetId" FROM "albums_assets_assets" "albums_assets" WHERE "albums_assets"."albumsId" = $1 AND "albums_assets"."assetsId" IN ($2, $3, $4) -- PARAMETERS: ["ca870d76-6311-4e89-bf9a-f5b51ea2452c","b666ae6c-afa8-4d6f-a1ad-7091a0659320","c656ab1c-7775-4ff7-b56f-01308c072a76","cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9"]
// Permissions check (1 query per asset)
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["b666ae6c-afa8-4d6f-a1ad-7091a0659320","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["c656ab1c-7775-4ff7-b56f-01308c072a76","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
```
2023-10-23 15:02:27 +02:00
|
|
|
const existingAssetIds = await this.albumRepository.getAssetIds(id, dto.ids);
|
|
|
|
|
2023-08-02 03:29:14 +02:00
|
|
|
const results: BulkIdResponseDto[] = [];
|
2023-10-18 17:56:00 +02:00
|
|
|
for (const assetId of dto.ids) {
|
fix(server): Check album asset membership in bulk (#4603)
Add `AlbumRepository` method to retrieve an album's asset ids, with an
optional parameter to only filter by the provided asset ids. With this,
we can now check asset membership using a single query.
When adding or removing assets to an album, checking whether each asset
is already present in the album now requires a single query, instead of
one query per asset.
Related to #4539 performance improvements.
Before:
```
// Asset membership and permissions check (2 queries per asset)
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "albums" "AlbumEntity" LEFT JOIN "albums_assets_assets" "AlbumEntity_AlbumEntity__AlbumEntity_assets" ON "AlbumEntity_AlbumEntity__AlbumEntity_assets"."albumsId"="AlbumEntity"."id" LEFT JOIN "assets" "AlbumEntity__AlbumEntity_assets" ON "AlbumEntity__AlbumEntity_assets"."id"="AlbumEntity_AlbumEntity__AlbumEntity_assets"."assetsId" AND ("AlbumEntity__AlbumEntity_assets"."deletedAt" IS NULL) WHERE ( ("AlbumEntity"."id" = $1 AND "AlbumEntity__AlbumEntity_assets"."id" = $2) ) AND ( "AlbumEntity"."deletedAt" IS NULL )) LIMIT 1 -- PARAMETERS: ["3fdf0e58-a1c7-4efe-8288-06e4c3f38df9","b666ae6c-afa8-4d6f-a1ad-7091a0659320"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["b666ae6c-afa8-4d6f-a1ad-7091a0659320","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "albums" "AlbumEntity" LEFT JOIN "albums_assets_assets" "AlbumEntity_AlbumEntity__AlbumEntity_assets" ON "AlbumEntity_AlbumEntity__AlbumEntity_assets"."albumsId"="AlbumEntity"."id" LEFT JOIN "assets" "AlbumEntity__AlbumEntity_assets" ON "AlbumEntity__AlbumEntity_assets"."id"="AlbumEntity_AlbumEntity__AlbumEntity_assets"."assetsId" AND ("AlbumEntity__AlbumEntity_assets"."deletedAt" IS NULL) WHERE ( ("AlbumEntity"."id" = $1 AND "AlbumEntity__AlbumEntity_assets"."id" = $2) ) AND ( "AlbumEntity"."deletedAt" IS NULL )) LIMIT 1 -- PARAMETERS: ["3fdf0e58-a1c7-4efe-8288-06e4c3f38df9","c656ab1c-7775-4ff7-b56f-01308c072a76"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["c656ab1c-7775-4ff7-b56f-01308c072a76","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "albums" "AlbumEntity" LEFT JOIN "albums_assets_assets" "AlbumEntity_AlbumEntity__AlbumEntity_assets" ON "AlbumEntity_AlbumEntity__AlbumEntity_assets"."albumsId"="AlbumEntity"."id" LEFT JOIN "assets" "AlbumEntity__AlbumEntity_assets" ON "AlbumEntity__AlbumEntity_assets"."id"="AlbumEntity_AlbumEntity__AlbumEntity_assets"."assetsId" AND ("AlbumEntity__AlbumEntity_assets"."deletedAt" IS NULL) WHERE ( ("AlbumEntity"."id" = $1 AND "AlbumEntity__AlbumEntity_assets"."id" = $2) ) AND ( "AlbumEntity"."deletedAt" IS NULL )) LIMIT 1 -- PARAMETERS: ["3fdf0e58-a1c7-4efe-8288-06e4c3f38df9","cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
```
After:
```
// Asset membership check (1 query for all assets)
immich_server | query: SELECT "albums_assets"."assetsId" AS "assetId" FROM "albums_assets_assets" "albums_assets" WHERE "albums_assets"."albumsId" = $1 AND "albums_assets"."assetsId" IN ($2, $3, $4) -- PARAMETERS: ["ca870d76-6311-4e89-bf9a-f5b51ea2452c","b666ae6c-afa8-4d6f-a1ad-7091a0659320","c656ab1c-7775-4ff7-b56f-01308c072a76","cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9"]
// Permissions check (1 query per asset)
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["b666ae6c-afa8-4d6f-a1ad-7091a0659320","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["c656ab1c-7775-4ff7-b56f-01308c072a76","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
immich_server | query: SELECT 1 AS "row_exists" FROM (SELECT 1 AS dummy_column) "dummy_table" WHERE EXISTS (SELECT 1 FROM "assets" "AssetEntity" WHERE ("AssetEntity"."id" = $1 AND "AssetEntity"."ownerId" = $2)) LIMIT 1 -- PARAMETERS: ["cf82adb2-1fcc-4f9e-9013-8fc03cc8d3a9","6bc60cf1-bd18-4501-a1c2-120b51276fda"]
```
2023-10-23 15:02:27 +02:00
|
|
|
const hasAsset = existingAssetIds.has(assetId);
|
2023-08-02 03:29:14 +02:00
|
|
|
if (!hasAsset) {
|
2023-10-18 17:56:00 +02:00
|
|
|
results.push({ id: assetId, success: false, error: BulkIdErrorReason.NOT_FOUND });
|
2023-08-02 03:29:14 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const hasAccess = await this.access.hasAny(authUser, [
|
2023-10-18 17:56:00 +02:00
|
|
|
{ permission: Permission.ALBUM_REMOVE_ASSET, id: assetId },
|
|
|
|
{ permission: Permission.ASSET_SHARE, id: assetId },
|
2023-08-02 03:29:14 +02:00
|
|
|
]);
|
|
|
|
if (!hasAccess) {
|
2023-10-18 17:56:00 +02:00
|
|
|
results.push({ id: assetId, success: false, error: BulkIdErrorReason.NO_PERMISSION });
|
2023-08-02 03:29:14 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-10-18 17:56:00 +02:00
|
|
|
results.push({ id: assetId, success: true });
|
2023-08-02 03:29:14 +02:00
|
|
|
}
|
|
|
|
|
2023-10-18 17:56:00 +02:00
|
|
|
const removedIds = results.filter(({ success }) => success).map(({ id }) => id);
|
|
|
|
if (removedIds.length > 0) {
|
|
|
|
await this.albumRepository.removeAssets({ albumId: id, assetIds: removedIds });
|
|
|
|
await this.albumRepository.update({ id, updatedAt: new Date() });
|
|
|
|
if (album.albumThumbnailAssetId && removedIds.includes(album.albumThumbnailAssetId)) {
|
|
|
|
await this.albumRepository.updateThumbnails();
|
|
|
|
}
|
2023-08-02 03:29:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
2023-08-11 18:00:51 +02:00
|
|
|
async addUsers(authUser: AuthUserDto, id: string, dto: AddUsersDto): Promise<AlbumResponseDto> {
|
2023-06-28 15:56:24 +02:00
|
|
|
await this.access.requirePermission(authUser, Permission.ALBUM_SHARE, id);
|
|
|
|
|
2023-08-15 20:34:02 +02:00
|
|
|
const album = await this.findOrFail(id, { withAssets: false });
|
2023-06-07 16:37:25 +02:00
|
|
|
|
|
|
|
for (const userId of dto.sharedUserIds) {
|
2023-09-11 17:56:38 +02:00
|
|
|
if (album.ownerId === userId) {
|
|
|
|
throw new BadRequestException('Cannot be shared with owner');
|
|
|
|
}
|
|
|
|
|
2023-06-07 16:37:25 +02:00
|
|
|
const exists = album.sharedUsers.find((user) => user.id === userId);
|
|
|
|
if (exists) {
|
|
|
|
throw new BadRequestException('User already added');
|
|
|
|
}
|
|
|
|
|
|
|
|
const user = await this.userRepository.get(userId);
|
|
|
|
if (!user) {
|
|
|
|
throw new BadRequestException('User not found');
|
|
|
|
}
|
|
|
|
|
|
|
|
album.sharedUsers.push({ id: userId } as UserEntity);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.albumRepository
|
|
|
|
.update({
|
|
|
|
id: album.id,
|
|
|
|
updatedAt: new Date(),
|
|
|
|
sharedUsers: album.sharedUsers,
|
|
|
|
})
|
2023-08-15 20:34:02 +02:00
|
|
|
.then(mapAlbumWithoutAssets);
|
2023-06-07 16:37:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async removeUser(authUser: AuthUserDto, id: string, userId: string | 'me'): Promise<void> {
|
|
|
|
if (userId === 'me') {
|
|
|
|
userId = authUser.id;
|
|
|
|
}
|
|
|
|
|
2023-08-15 20:34:02 +02:00
|
|
|
const album = await this.findOrFail(id, { withAssets: false });
|
2023-06-07 16:37:25 +02:00
|
|
|
|
|
|
|
if (album.ownerId === userId) {
|
|
|
|
throw new BadRequestException('Cannot remove album owner');
|
|
|
|
}
|
|
|
|
|
|
|
|
const exists = album.sharedUsers.find((user) => user.id === userId);
|
|
|
|
if (!exists) {
|
|
|
|
throw new BadRequestException('Album not shared with user');
|
|
|
|
}
|
|
|
|
|
|
|
|
// non-admin can remove themselves
|
|
|
|
if (authUser.id !== userId) {
|
2023-06-28 15:56:24 +02:00
|
|
|
await this.access.requirePermission(authUser, Permission.ALBUM_SHARE, id);
|
2023-06-07 16:37:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
await this.albumRepository.update({
|
|
|
|
id: album.id,
|
|
|
|
updatedAt: new Date(),
|
|
|
|
sharedUsers: album.sharedUsers.filter((user) => user.id !== userId),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-08-15 20:34:02 +02:00
|
|
|
private async findOrFail(id: string, options: AlbumInfoOptions) {
|
|
|
|
const album = await this.albumRepository.getById(id, options);
|
2023-06-07 16:37:25 +02:00
|
|
|
if (!album) {
|
|
|
|
throw new BadRequestException('Album not found');
|
|
|
|
}
|
|
|
|
return album;
|
|
|
|
}
|
2023-03-26 04:46:48 +02:00
|
|
|
}
|