From 64bab02b7cf9e9c8bb5ba49fdbe6481f4f94bf9b Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Sun, 3 Apr 2022 00:15:06 +0530 Subject: [PATCH] fix: patch proto sync receipts --- src/Socket/messages-recv.ts | 3 ++- src/Socket/messages-send.ts | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index 7f14c75..42fcbff 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -152,7 +152,8 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { const normalizedContent = !!msg.message ? normalizeMessageContent(msg.message) : undefined const isAnyHistoryMsg = !!normalizedContent?.protocolMessage?.historySyncNotification if(isAnyHistoryMsg) { - await sendReceipt(msg.key.remoteJid!, undefined, [msg.key.id], 'hist_sync') + const jid = jidEncode(jidDecode(msg.key.remoteJid!).user, 'c.us') + await sendReceipt(jid, undefined, [msg.key.id], 'hist_sync') // we only want to sync app state once we've all the history // restart the app state sync timeout logger.debug('restarting app sync timeout') diff --git a/src/Socket/messages-send.ts b/src/Socket/messages-send.ts index 58b737f..964eb3b 100644 --- a/src/Socket/messages-send.ts +++ b/src/Socket/messages-send.ts @@ -85,10 +85,14 @@ export const makeMessagesSocket = (config: SocketConfig) => { tag: 'receipt', attrs: { id: messageIds[0], - t: Date.now().toString(), to: jid, }, } + const isProtoReceipt = type === 'hist_sync' || type === 'peer_msg' + if(!isProtoReceipt) { + node.attrs.t = Date.now().toString() + } + if(type) { node.attrs.type = type }