fix(server): allow an empty assetIds array when creating an album shared link (#31098)

This commit is contained in:
Ufuk
2026-08-31 17:31:47 +02:00
committed by GitHub
parent 0628f8b966
commit 9e5dcc598f
3 changed files with 22 additions and 1 deletions
@@ -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', () => { describe('PATCH /shared-links/:id', () => {
@@ -77,6 +77,17 @@ describe(SharedLinkController.name, () => {
); );
expect(service.create).not.toHaveBeenCalled(); 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', () => { describe('DELETE /shared-links/:id/assets', () => {
+1 -1
View File
@@ -37,7 +37,7 @@ const SharedLinkCreateSchema = z
if (!albumId) { if (!albumId) {
ctx.addIssue(`albumId is required for type ${SharedLinkType.Album}`); 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}`); ctx.addIssue(`assetIds can only be used with type ${SharedLinkType.Individual}`);
} }
return; return;