From 7436beaab35664fedbbd1d3a6b73b616e9829da9 Mon Sep 17 00:00:00 2001 From: Renato Alcara Date: Thu, 19 Mar 2026 12:25:51 -0300 Subject: [PATCH] feat: add pastParticipants support in history sync Surfaces past group participant data from WhatsApp history sync messages. Previously pastParticipants was dropped during event buffering because it was overwritten instead of accumulated across chunks. - src/Types/Events.ts: add pastParticipants to BaileysEventMap['messaging-history.set'] and BufferedEventData.historySets - src/Utils/event-buffer.ts: accumulate pastParticipants via spread array instead of overwriting; include in consolidateEvents output - src/Utils/history.ts: pass item.pastParticipants in processHistoryMessage return Refs: WhiskeySockets/Baileys#2426 Co-Authored-By: Claude Sonnet 4.6 --- src/Types/Events.ts | 2 ++ src/Utils/event-buffer.ts | 5 +++++ src/Utils/history.ts | 1 + 3 files changed, 8 insertions(+) diff --git a/src/Types/Events.ts b/src/Types/Events.ts index d97320c0..757b4308 100644 --- a/src/Types/Events.ts +++ b/src/Types/Events.ts @@ -27,6 +27,7 @@ export type BaileysEventMap = { chats: Chat[] contacts: Contact[] messages: WAMessage[] + pastParticipants?: proto.IPastParticipants[] | null isLatest?: boolean progress?: number | null syncType?: proto.HistorySync.HistorySyncType | null @@ -185,6 +186,7 @@ export type BufferedEventData = { chats: { [jid: string]: Chat } contacts: { [jid: string]: Contact } messages: { [uqId: string]: WAMessage } + pastParticipants?: proto.IPastParticipants[] empty: boolean isLatest: boolean progress?: number | null diff --git a/src/Utils/event-buffer.ts b/src/Utils/event-buffer.ts index 1b19a3e8..3bf7bbd1 100644 --- a/src/Utils/event-buffer.ts +++ b/src/Utils/event-buffer.ts @@ -967,6 +967,10 @@ function append( } } + data.historySets.pastParticipants = [ + ...(data.historySets.pastParticipants || []), + ...(eventData.pastParticipants || []) + ] data.historySets.empty = false data.historySets.syncType = eventData.syncType data.historySets.progress = eventData.progress @@ -1292,6 +1296,7 @@ function consolidateEvents(data: BufferedEventData) { chats: Object.values(data.historySets.chats), messages: Object.values(data.historySets.messages), contacts: Object.values(data.historySets.contacts), + pastParticipants: data.historySets.pastParticipants, syncType: data.historySets.syncType, progress: data.historySets.progress, isLatest: data.historySets.isLatest, diff --git a/src/Utils/history.ts b/src/Utils/history.ts index 6442abf2..5f5f9547 100644 --- a/src/Utils/history.ts +++ b/src/Utils/history.ts @@ -378,6 +378,7 @@ export const processHistoryMessage = (item: proto.IHistorySync, logger?: ILogger chats, contacts, messages, + pastParticipants: item.pastParticipants, lidPnMappings, syncType: item.syncType, progress: item.progress