From 164421fe6035457f35247f4a4b855165e7d1a503 Mon Sep 17 00:00:00 2001 From: "Gerson K. M." Date: Wed, 5 Aug 2026 01:43:20 -0300 Subject: [PATCH] fix(baileys): expose delivery receipts for group messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Baileys routes receipts for group messages to `message-receipt.update` instead of `messages.update` (see `handleReceipt` in messages-recv.ts). In that branch, delivery arrives as `receiptTimestamp` while read arrives as `readTimestamp` — but only `readTimestamp` was being consumed, and `sendDataWebhook` was never called. The practical effect is that delivery confirmation for group messages never reaches the webhook. Individual chats confirm normally (SERVER_ACK, DELIVERY_ACK, READ); groups produce no event at all, even though WhatsApp does send the receipt and Baileys does receive it — one per participant. Verified on 2.3.7 with `LOG_BAILEYS=debug`: a single group message produced four `tag: "receipt"` stanzas, and zero webhook calls. This emits MESSAGES_UPDATE using the same flat payload as the individual-chat branch, so no new event type is needed and existing consumers keep working — `participant` is already part of the status schema. The existing `readTimestamp` handling is untouched. --- .../channel/whatsapp/whatsapp.baileys.service.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts index 22839fd451..be7282ba13 100644 --- a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts @@ -2163,6 +2163,19 @@ export class BaileysStartupService extends ChannelStartupService { const remotesJidMap: Record = {}; for (const event of payload) { + // Group receipts arrive here instead of `messages.update`, with + // delivery carried by `receiptTimestamp` and read by `readTimestamp` + // (Baileys sets exactly one of them per event). Only the latter was + // consumed, so group delivery never reached the webhook. + this.sendDataWebhook(Events.MESSAGES_UPDATE, { + keyId: event.key.id, + remoteJid: event.key.remoteJid, + fromMe: event.key.fromMe, + participant: event.receipt.userJid, + status: typeof event.receipt.receiptTimestamp === 'number' ? 'DELIVERY_ACK' : 'READ', + instanceId: this.instanceId, + }); + if (typeof event.key.remoteJid === 'string' && typeof event.receipt.readTimestamp === 'number') { remotesJidMap[event.key.remoteJid] = event.receipt.readTimestamp; }