Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(integration): persist the ingress request method with the event
Yudhi Armyndharis090dca178d60
diff --git a/src/modules/integration/ingress-event.service.ts b/src/modules/integration/ingress-event.service.tsindex 5fe3085e4..053954b5e 100644--- a/src/modules/integration/ingress-event.service.ts+++ b/src/modules/integration/ingress-event.service.ts@@ -11,7 +11,7 @@ export interface IngressEventInput {pluginId: string;providerDeliveryId: string;route: string;- payload: { headers: Record<string, string>; query: Record<string, string>; body: string; rawBody: string };+ payload: NonNullable<IngressEvent['payload']>;// sha256 hex of payload.rawBody — the slim content fingerprint that survives payload retirement.payloadHash: string;sessionId: string | null;diff --git a/src/modules/integration/ingress.service.spec.ts b/src/modules/integration/ingress.service.spec.tsindex 6718d5399..27cf745bb 100644--- a/src/modules/integration/ingress.service.spec.ts+++ b/src/modules/integration/ingress.service.spec.ts@@ -149,6 +149,18 @@ describe('IngressService.handle', () => {expect(res.status).toBe(202);});+ it('persists the request method so a replay keeps it', async () => {+ const d = deps();+ await new IngressService(d).handle({ ...req, method: 'PUT' });+ expect(d.events.recordOrSkip).toHaveBeenCalledWith(+ expect.objectContaining({ payload: expect.objectContaining({ method: 'PUT' }) }),+ );+ expect(d.enqueue).toHaveBeenCalledWith(+ expect.objectContaining({ method: 'PUT', payload: expect.not.objectContaining({ method: 'PUT' }) }),+ 'd1',+ );+ });+// A body no parser read would be handled as the empty body: it passes a header-only scheme, and every// such delivery hashes to the same dedup key, so all but the first are acked and dropped.it('refuses a body in a content type no parser read (415), before anything is persisted', async () => {diff --git a/src/modules/integration/ingress.service.ts b/src/modules/integration/ingress.service.tsindex 1a722978a..607fd97a8 100644--- a/src/modules/integration/ingress.service.ts+++ b/src/modules/integration/ingress.service.ts@@ -49,7 +49,13 @@ export interface IngressDeps {pluginId: string;providerDeliveryId: string;route: string;- payload: { headers: Record<string, string>; query: Record<string, string>; body: string; rawBody: string };+ payload: {+ headers: Record<string, string>;+ query: Record<string, string>;+ body: string;+ rawBody: string;+ method?: string;+ };payloadHash: string;sessionId: string | null;}): Promise<boolean>;@@ -237,7 +243,8 @@ export class IngressService {pluginId: req.pluginId,providerDeliveryId: deliveryId,route: req.route,- payload,+ // The method rides with the row so a reconciler replay reaches the handler as this attempt does.+ payload: { ...payload, method: req.method },// The slim content fingerprint kept after the payload is retired on dispatch (see the entity).payloadHash: createHash('sha256').update(req.rawBody).digest('hex'),sessionId: instance.sessionScope,