mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
fix(web/server) uploaded asset in shared link not loaded (#1766)
* fix(web/server): Uploaded asset to shared link does not get added to the shared link/album * remove unused code * Add endpoints for each remove and add assets to shared link * Update api * Added deletion logic * Convert callback to async/await * Fix linter * Fix test * Fix server test * added test * Test coverage * modify DTO * Add notification * fix test
This commit is contained in:
@@ -63,13 +63,24 @@ export class ShareCore {
|
||||
return this.repository.remove(link);
|
||||
}
|
||||
|
||||
async updateAssets(userId: string, id: string, assets: AssetEntity[]) {
|
||||
async addAssets(userId: string, id: string, assets: AssetEntity[]) {
|
||||
const link = await this.get(userId, id);
|
||||
if (!link) {
|
||||
throw new BadRequestException('Shared link not found');
|
||||
}
|
||||
|
||||
return this.repository.save({ ...link, assets });
|
||||
return this.repository.save({ ...link, assets: [...link.assets, ...assets] });
|
||||
}
|
||||
|
||||
async removeAssets(userId: string, id: string, assets: AssetEntity[]) {
|
||||
const link = await this.get(userId, id);
|
||||
if (!link) {
|
||||
throw new BadRequestException('Shared link not found');
|
||||
}
|
||||
|
||||
const newAssets = link.assets.filter((asset) => assets.find((a) => a.id === asset.id));
|
||||
|
||||
return this.repository.save({ ...link, assets: newAssets });
|
||||
}
|
||||
|
||||
async hasAssetAccess(id: string, assetId: string): Promise<boolean> {
|
||||
|
||||
Reference in New Issue
Block a user