Skip to content

Commit 164421f

Browse files
committed
fix(baileys): expose delivery receipts for group messages
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.
1 parent e273b90 commit 164421f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,6 +2163,19 @@ export class BaileysStartupService extends ChannelStartupService {
21632163
const remotesJidMap: Record<string, number> = {};
21642164

21652165
for (const event of payload) {
2166+
// Group receipts arrive here instead of `messages.update`, with
2167+
// delivery carried by `receiptTimestamp` and read by `readTimestamp`
2168+
// (Baileys sets exactly one of them per event). Only the latter was
2169+
// consumed, so group delivery never reached the webhook.
2170+
this.sendDataWebhook(Events.MESSAGES_UPDATE, {
2171+
keyId: event.key.id,
2172+
remoteJid: event.key.remoteJid,
2173+
fromMe: event.key.fromMe,
2174+
participant: event.receipt.userJid,
2175+
status: typeof event.receipt.receiptTimestamp === 'number' ? 'DELIVERY_ACK' : 'READ',
2176+
instanceId: this.instanceId,
2177+
});
2178+
21662179
if (typeof event.key.remoteJid === 'string' && typeof event.receipt.readTimestamp === 'number') {
21672180
remotesJidMap[event.key.remoteJid] = event.receipt.readTimestamp;
21682181
}

0 commit comments

Comments
 (0)