history: improve history sync and support new payload
This commit is contained in:
@@ -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
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user