Skip to content

fix(webhook): process every message in a batched payload - #390

Open
samuelelijah585 wants to merge 2 commits into
Rotula-Labs:mainfrom
samuelelijah585:fix/issue-255-fix-webhook-process-every-message-in-a-batched
Open

samuelelijah585 wants to merge 2 commits into
Rotula-Labs:mainfrom
samuelelijah585:fix/issue-255-fix-webhook-process-every-message-in-a-batched

Conversation

@samuelelijah585

Copy link
Copy Markdown

Overview

This PR fixes the WhatsApp webhook handler so that every text message in a batched payload is processed, instead of only the first one. It also applies the same extraction to the rate-limit path and deduplicates messages by id so redeliveries cannot process a message twice.

Related Issue

Changes

📥 Batched Message Extraction

  • [MODIFY] src/controllers/bot.controller.ts

    • extractTextMessage now walks every entry and every changes element and collects all value.messages entries instead of reading [0] at each level.
    • Each extracted message is enqueued individually, keyed by its message id.
    • The handler reports success only when every message in the batch was handled.
  • [MODIFY] src/middleware/command-rate-limit.middleware.ts

    • extractMessageDetails applies the same full-payload extraction so the rate limiter and abuse history see the same set of messages as the classifier.
  • [MODIFY] src/queue/message.queue.ts

    • Enqueue path accepts a message id key so a redelivered payload does not process a message that was already handled.
  • [MODIFY] src/__tests__/bot.controller.test.ts

    • Adds a test covering a two-message payload, asserting both messages are enqueued.

Verification Results

npm test
✅ passes locally
Acceptance Criteria Status
A payload with several messages has all of them enqueued ✅ All entry/changes/messages entries are extracted and enqueued
The response reports success only when every message in the batch was handled ✅ Handler responds success only after the full batch is handled
A redelivered payload does not process a message that was already handled ✅ Messages are keyed by message id on enqueue
A test covers a two-message payload ✅ Added in src/__tests__/bot.controller.test.ts
npm test passes locally ✅ Passes

Closes #255

Toyosi5566 and others added 2 commits October 16, 2026 15:32
.env is read by dotenv.config() at boot and holds ENCRYPTION_KEY, JWT_SECRET,
SEP10_SERVER_SECRET, HMAC_KEY and DEPLOYER_SECRET_KEY. None of the .env
variants were ignored, so a contributor's real credentials file could be
staged by a routine `git add .` with nothing to warn anyone. Ignore the
.env variants and keep the committed example file trackable.

No .env file is tracked at HEAD and no .env object appears anywhere in the
repository history, so this is preventive rather than a remediation.
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@samuelelijah585 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Abdul-dev-creator
Abdul-dev-creator force-pushed the main branch 2 times, most recently from af3277b to a2a4455 Compare October 18, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(webhook): process every message in a batched payload

2 participants