Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(webhook): say an update without filters keeps the stored filter
Yudhi Armyndharisc9779d2faea7
diff --git a/src/modules/webhook/dto/webhook.dto.spec.ts b/src/modules/webhook/dto/webhook.dto.spec.tsindex d1ae9b1c6..3a07cc289 100644--- a/src/modules/webhook/dto/webhook.dto.spec.ts+++ b/src/modules/webhook/dto/webhook.dto.spec.ts@@ -52,6 +52,18 @@ describe('webhook DTO event validation', () => {expect(await errorsFor(UpdateWebhookDto, {})).toHaveLength(0);expect(await errorsFor(UpdateWebhookDto, { filters: null })).toHaveLength(0);});++ // WebhookService.update applies filters only when the field is present, so an update that omits it+ // keeps the stored filter. The published schema must not offer omission as a way to clear one.+ it('UpdateWebhookDto: documents that an omitted filters keeps the stored one', () => {+ const descriptionOf = (target: object): string | undefined =>+ (Reflect.getMetadata('swagger/apiModelProperties', target, 'filters') as { description?: string } | undefined)+ ?.description;++ expect(descriptionOf(UpdateWebhookDto.prototype)).toContain('Omit to keep the stored filters');+ expect(descriptionOf(UpdateWebhookDto.prototype)).not.toContain('Omit or null to fire');+ expect(descriptionOf(CreateWebhookDto.prototype)).toContain('Omit or null to fire');+ });});describe('webhook DTO custom-header validation', () => {diff --git a/src/modules/webhook/dto/webhook.dto.ts b/src/modules/webhook/dto/webhook.dto.tsindex e4d8fc506..3d8179d02 100644--- a/src/modules/webhook/dto/webhook.dto.ts+++ b/src/modules/webhook/dto/webhook.dto.ts@@ -58,6 +58,9 @@ class WebhookFiltersDto {const FILTERS_API_DESCRIPTION ='Optional smart pre-filter. When set, every condition must match (AND) for the webhook to fire. Omit or null to fire on every subscribed event.';+// An update applies `filters` only when the field is present, so omission keeps the stored filter.+const UPDATE_FILTERS_API_DESCRIPTION =+ 'Optional smart pre-filter. When set, every condition must match (AND) for the webhook to fire. Omit to keep the stored filters; send null or { conditions: [] } to clear them, so the webhook fires on every subscribed event.';const FILTERS_API_EXAMPLE = {conditions: [{ field: 'sender', operator: 'is', value: ['[email protected]'] },@@ -245,7 +248,7 @@ export class UpdateWebhookDto {// sends and accepts.@ApiPropertyOptional({type: WebhookFiltersDto,- description: FILTERS_API_DESCRIPTION,+ description: UPDATE_FILTERS_API_DESCRIPTION,example: FILTERS_API_EXAMPLE,nullable: true,})