diff --git a/e2e/src/specs/server/api/shared-link.e2e-spec.ts b/e2e/src/specs/server/api/shared-link.e2e-spec.ts index 4e5988a16..6fec58c24 100644 --- a/e2e/src/specs/server/api/shared-link.e2e-spec.ts +++ b/e2e/src/specs/server/api/shared-link.e2e-spec.ts @@ -330,6 +330,16 @@ describe('/shared-links', () => { }), ); }); + + it('should create an album shared link when the client sends an empty assetIds array', async () => { + const { status, body } = await request(app) + .post('/shared-links') + .set('Authorization', `Bearer ${user1.accessToken}`) + .send({ type: SharedLinkType.Album, albumId: album.id, assetIds: [] }); + + expect(status).toBe(201); + expect(body).toEqual(expect.objectContaining({ type: SharedLinkType.Album, userId: user1.userId })); + }); }); describe('PATCH /shared-links/:id', () => { diff --git a/server/src/controllers/shared-link.controller.spec.ts b/server/src/controllers/shared-link.controller.spec.ts index 856a74e34..ee5c3c69c 100644 --- a/server/src/controllers/shared-link.controller.spec.ts +++ b/server/src/controllers/shared-link.controller.spec.ts @@ -77,6 +77,17 @@ describe(SharedLinkController.name, () => { ); expect(service.create).not.toHaveBeenCalled(); }); + + it('should allow an empty assetIds array for share type Album', async () => { + const albumId = newUuid(); + await request(ctx.getHttpServer()) + .post('/shared-links') + .send({ type: SharedLinkType.Album, albumId, assetIds: [] }); + expect(service.create).toHaveBeenCalledWith( + undefined, + expect.objectContaining({ type: SharedLinkType.Album, albumId }), + ); + }); }); describe('DELETE /shared-links/:id/assets', () => { diff --git a/server/src/dtos/shared-link.dto.ts b/server/src/dtos/shared-link.dto.ts index d22875f28..a54b3afc4 100644 --- a/server/src/dtos/shared-link.dto.ts +++ b/server/src/dtos/shared-link.dto.ts @@ -37,7 +37,7 @@ const SharedLinkCreateSchema = z if (!albumId) { ctx.addIssue(`albumId is required for type ${SharedLinkType.Album}`); } - if (assetIds) { + if (assetIds && assetIds.length > 0) { ctx.addIssue(`assetIds can only be used with type ${SharedLinkType.Individual}`); } return;