diff --git a/src/Defaults/index.ts b/src/Defaults/index.ts index 21fed6b2..3f966b3b 100644 --- a/src/Defaults/index.ts +++ b/src/Defaults/index.ts @@ -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 = { diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index cae897fd..f9a767ca 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -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 diff --git a/src/Utils/history.ts b/src/Utils/history.ts index b2557a80..57f47614 100644 --- a/src/Utils/history.ts +++ b/src/Utils/history.ts @@ -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) }