fix(server): require asset permission when creating an album with them (#8686)

require asset permission when creating an album with them
This commit is contained in:
Daniel Dietzler
2024-04-10 19:41:22 +02:00
committed by GitHub
parent 56079527ef
commit ad5d115abe
3 changed files with 41 additions and 3 deletions

View File

@@ -119,13 +119,16 @@ export class AlbumService {
}
}
const allowedAssetIdsSet = await this.access.checkAccess(auth, Permission.ASSET_SHARE, new Set(dto.assetIds));
const assets = [...allowedAssetIdsSet].map((id) => ({ id }) as AssetEntity);
const album = await this.albumRepository.create({
ownerId: auth.user.id,
albumName: dto.albumName,
description: dto.description,
sharedUsers: dto.sharedWithUserIds?.map((value) => ({ id: value }) as UserEntity) ?? [],
assets: (dto.assetIds || []).map((id) => ({ id }) as AssetEntity),
albumThumbnailAssetId: dto.assetIds?.[0] || null,
assets,
albumThumbnailAssetId: assets[0]?.id || null,
});
return mapAlbumWithAssets(album);