Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(label): say an upsert replaces the whole label
Yudhi Armyndharis57a080c967ee
diff --git a/src/modules/label/label.service.spec.ts b/src/modules/label/label.service.spec.tsindex 499acfb25..959b68e19 100644--- a/src/modules/label/label.service.spec.ts+++ b/src/modules/label/label.service.spec.ts@@ -108,8 +108,9 @@ describe('LabelService label editing', () => {expect(upsertLabel).toHaveBeenCalledWith({ id: 'l1', name: 'VIP' });});- // Omitted fields must stay omitted rather than becoming undefined-valued keys: the adapter drops- // undefined before it reaches app-state, and sending an explicit blank would clear the field.+ // Omitted fields must stay omitted rather than becoming undefined-valued keys. The service sends+ // only the fields the caller set, and the adapter forwards them unchanged; the write replaces the+ // whole label.it('passes through only the fields the caller set', async () => {const upsertLabel = jest.fn().mockResolvedValue(undefined);await makeService({ upsertLabel }).upsertLabel('s1', 'l1', { color: 3 });diff --git a/src/modules/label/label.service.ts b/src/modules/label/label.service.tsindex 4b05559c3..7c20984eb 100644--- a/src/modules/label/label.service.ts+++ b/src/modules/label/label.service.ts@@ -37,9 +37,9 @@ export class LabelService {* already exists — which is also why the caller chooses the id rather than being handed one.*/upsertLabel(sessionId: string, labelId: string, body: { name?: string; color?: number }) {- // Both fields are individually optional (either alone is a valid partial update), but a body- // that sets neither has nothing to write — on an unused id it would even create a nameless- // label — so it is refused like the group-settings PUT refuses an empty patch. `null` counts as+ // Both fields are individually optional, but the write replaces the whole label, so an omitted+ // field is not kept (a colour-only write clears the name). A body that sets neither has nothing to+ // write, so it is refused like the group-settings PUT refuses an empty patch. `null` counts as// "not set": class-validator's @IsOptional skips validation for it and class-transformer keeps// it, so {"name": null} reached here as an explicit nothing.const name = body.name ?? undefined;