Compare commits

...

1 Commits

Author SHA1 Message Date
Daniel Dietzler d3a7f1b9c2 fix: emit album update event when uploading assets through shared link 2026-07-09 13:18:00 +02:00
2 changed files with 19 additions and 3 deletions
+14 -3
View File
@@ -342,9 +342,20 @@ export class AssetMediaService extends BaseService {
}
private async addToSharedLink(sharedLink: AuthSharedLink, assetId: string) {
await (sharedLink.albumId
? this.albumRepository.addAssetIds(sharedLink.albumId, [assetId])
: this.sharedLinkRepository.addAssets(sharedLink.id, [assetId]));
if (!sharedLink.albumId) {
await this.sharedLinkRepository.addAssets(sharedLink.id, [assetId]);
return;
}
const album = await this.albumRepository.getById(sharedLink.albumId, { withAssets: false });
if (!album) {
return;
}
await this.albumRepository.addAssetIds(album.id, [assetId]);
for (const { user } of album.albumUsers) {
await this.eventRepository.emit('AlbumUpdate', { id: album.id, recipientId: user.id });
}
}
private requireQuota(auth: AuthDto, size: number) {
@@ -213,6 +213,11 @@ describe(AssetService.name, () => {
const assets = [...result];
expect(assets).toHaveLength(1);
expect(assets[0]).toEqual(response.id);
expect(ctx.getMock(EventRepository).emit).toHaveBeenCalledWith('AlbumUpdate', {
id: album.id,
recipientId: user.id,
});
});
it('should handle adding a duplicate asset to an album shared link', async () => {