history: improve history sync and support new payload

This commit is contained in:
Rajeh Taher
2025-11-06 23:52:38 +02:00
parent a8b8eceb72
commit abf5af0e72
3 changed files with 14 additions and 9 deletions
+7 -7
View File
@@ -35,13 +35,13 @@ export const WA_CERT_DETAILS = {
}
export const PROCESSABLE_HISTORY_TYPES = [
proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_BOOTSTRAP,
proto.Message.HistorySyncNotification.HistorySyncType.PUSH_NAME,
proto.Message.HistorySyncNotification.HistorySyncType.RECENT,
proto.Message.HistorySyncNotification.HistorySyncType.FULL,
proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND,
proto.Message.HistorySyncNotification.HistorySyncType.NON_BLOCKING_DATA,
proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_STATUS_V3
proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
proto.HistorySync.HistorySyncType.PUSH_NAME,
proto.HistorySync.HistorySyncType.RECENT,
proto.HistorySync.HistorySyncType.FULL,
proto.HistorySync.HistorySyncType.ON_DEMAND,
proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3,
]
export const DEFAULT_CONNECTION_CONFIG: SocketConfig = {
+1 -1
View File
@@ -1036,7 +1036,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
const historyMsg = getHistoryMsg(msg.message!)
const shouldProcessHistoryMsg = historyMsg
? shouldSyncHistoryMessage(historyMsg) && PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType!)
? shouldSyncHistoryMessage(historyMsg) && PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType! as proto.HistorySync.HistorySyncType)
: false
// State machine: decide on sync and flush
+6 -1
View File
@@ -96,7 +96,12 @@ export const downloadAndProcessHistorySyncNotification = async (
msg: proto.Message.IHistorySyncNotification,
options: RequestInit
) => {
const historyMsg = await downloadHistory(msg, options)
let historyMsg: proto.HistorySync
if (msg.initialHistBootstrapInlinePayload) {
historyMsg = proto.HistorySync.decode(await inflatePromise(msg.initialHistBootstrapInlinePayload))
} else {
historyMsg = await downloadHistory(msg, options)
}
return processHistoryMessage(historyMsg)
}