Skip to content

Commit abf5af0

Browse files
committed
history: improve history sync and support new payload
1 parent a8b8ece commit abf5af0

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/Defaults/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ export const WA_CERT_DETAILS = {
3535
}
3636

3737
export const PROCESSABLE_HISTORY_TYPES = [
38-
proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_BOOTSTRAP,
39-
proto.Message.HistorySyncNotification.HistorySyncType.PUSH_NAME,
40-
proto.Message.HistorySyncNotification.HistorySyncType.RECENT,
41-
proto.Message.HistorySyncNotification.HistorySyncType.FULL,
42-
proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND,
43-
proto.Message.HistorySyncNotification.HistorySyncType.NON_BLOCKING_DATA,
44-
proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_STATUS_V3
38+
proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
39+
proto.HistorySync.HistorySyncType.PUSH_NAME,
40+
proto.HistorySync.HistorySyncType.RECENT,
41+
proto.HistorySync.HistorySyncType.FULL,
42+
proto.HistorySync.HistorySyncType.ON_DEMAND,
43+
proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
44+
proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3,
4545
]
4646

4747
export const DEFAULT_CONNECTION_CONFIG: SocketConfig = {

src/Socket/chats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
10361036

10371037
const historyMsg = getHistoryMsg(msg.message!)
10381038
const shouldProcessHistoryMsg = historyMsg
1039-
? shouldSyncHistoryMessage(historyMsg) && PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType!)
1039+
? shouldSyncHistoryMessage(historyMsg) && PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType! as proto.HistorySync.HistorySyncType)
10401040
: false
10411041

10421042
// State machine: decide on sync and flush

src/Utils/history.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ export const downloadAndProcessHistorySyncNotification = async (
9696
msg: proto.Message.IHistorySyncNotification,
9797
options: RequestInit
9898
) => {
99-
const historyMsg = await downloadHistory(msg, options)
99+
let historyMsg: proto.HistorySync
100+
if (msg.initialHistBootstrapInlinePayload) {
101+
historyMsg = proto.HistorySync.decode(await inflatePromise(msg.initialHistBootstrapInlinePayload))
102+
} else {
103+
historyMsg = await downloadHistory(msg, options)
104+
}
100105
return processHistoryMessage(historyMsg)
101106
}
102107

0 commit comments

Comments
 (0)