Skip to content

Commit c55a529

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 c55a529

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

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

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

21652165
for (const event of payload) {
2166+
// Baileys routes receipts for GROUP messages to `message-receipt.update`
2167+
// instead of `messages.update` (see handleReceipt in messages-recv.ts).
2168+
// Delivery arrives here as `receiptTimestamp`, while only `readTimestamp`
2169+
// was being consumed below — so delivery confirmation for group messages
2170+
// never reached the webhook, and integrators had no way to observe it.
2171+
//
2172+
// Emitted as MESSAGES_UPDATE with the same flat payload used by the
2173+
// individual-chat branch, so no new event type is required and existing
2174+
// consumers keep working. `participant` is already part of the schema.
2175+
this.sendDataWebhook(Events.MESSAGES_UPDATE, {
2176+
keyId: event.key.id,
2177+
remoteJid: event.key.remoteJid,
2178+
fromMe: event.key.fromMe,
2179+
participant: event.receipt.userJid,
2180+
status: typeof event.receipt.receiptTimestamp === 'number' ? 'DELIVERY_ACK' : 'READ',
2181+
instanceId: this.instanceId,
2182+
});
2183+
21662184
if (typeof event.key.remoteJid === 'string' && typeof event.receipt.readTimestamp === 'number') {
21672185
remotesJidMap[event.key.remoteJid] = event.receipt.readTimestamp;
21682186
}

0 commit comments

Comments
 (0)