From 8242ff9babc31c82aab4fe336dc34fa5b426267c Mon Sep 17 00:00:00 2001 From: PyKen Date: Tue, 8 Apr 2025 06:19:06 +0200 Subject: [PATCH] fix(server): Exclude album assets in shared link payload (#17207) * fix(server): Exclude album assets in shared link payload * Fix e2e test --- e2e/src/api/specs/shared-link.e2e-spec.ts | 10 +--------- server/src/dtos/shared-link.dto.ts | 5 +---- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/e2e/src/api/specs/shared-link.e2e-spec.ts b/e2e/src/api/specs/shared-link.e2e-spec.ts index afad771bfc..04ed8ca0a4 100644 --- a/e2e/src/api/specs/shared-link.e2e-spec.ts +++ b/e2e/src/api/specs/shared-link.e2e-spec.ts @@ -246,15 +246,7 @@ describe('/shared-links', () => { const { status, body } = await request(app).get('/shared-links/me').query({ key: linkWithMetadata.key }); expect(status).toBe(200); - expect(body.assets).toHaveLength(1); - expect(body.assets[0]).toEqual( - expect.objectContaining({ - originalFileName: 'example.png', - localDateTime: expect.any(String), - fileCreatedAt: expect.any(String), - exifInfo: expect.any(Object), - }), - ); + expect(body.assets).toHaveLength(0); expect(body.album).toBeDefined(); }); diff --git a/server/src/dtos/shared-link.dto.ts b/server/src/dtos/shared-link.dto.ts index e3f8c72e19..6bb8ab1f0d 100644 --- a/server/src/dtos/shared-link.dto.ts +++ b/server/src/dtos/shared-link.dto.ts @@ -104,9 +104,6 @@ export class SharedLinkResponseDto { export function mapSharedLink(sharedLink: SharedLinkEntity): SharedLinkResponseDto { const linkAssets = sharedLink.assets || []; - const albumAssets = (sharedLink?.album?.assets || []).map((asset) => asset); - - const assets = _.uniqBy([...linkAssets, ...albumAssets], (asset) => asset.id); return { id: sharedLink.id, @@ -117,7 +114,7 @@ export function mapSharedLink(sharedLink: SharedLinkEntity): SharedLinkResponseD type: sharedLink.type, createdAt: sharedLink.createdAt, expiresAt: sharedLink.expiresAt, - assets: assets.map((asset) => mapAsset(asset)), + assets: linkAssets.map((asset) => mapAsset(asset)), album: sharedLink.album ? mapAlbumWithoutAssets(sharedLink.album) : undefined, allowUpload: sharedLink.allowUpload, allowDownload: sharedLink.allowDownload,