mirror of
https://github.com/immich-app/immich.git
synced 2026-07-09 21:52:34 -07:00
fix: emit album update event when uploading assets through shared link
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user