From 196be24e4f0dd23fd25084bc7bbb74aca4293eb1 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Sat, 28 Nov 2020 13:26:31 +0530 Subject: [PATCH] Update messageID generation + use archive property in chat key --- src/WAConnection/Utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WAConnection/Utils.ts b/src/WAConnection/Utils.ts index 733d4e4..04a89e8 100644 --- a/src/WAConnection/Utils.ts +++ b/src/WAConnection/Utils.ts @@ -26,7 +26,7 @@ export const Browsers = { } export const toNumber = (t: Long | number) => (t['low'] || t) as number export const waChatKey = (pin: boolean) => ({ - key: (c: WAChat) => (pin ? (c.pin ? '1' : '0') : '') + c.t.toString(16).padStart(8, '0') + c.jid, + key: (c: WAChat) => (pin ? (c.pin ? '1' : '0') : '') + (c.archive === 'true' ? '0' : '1') + c.t.toString(16).padStart(8, '0') + c.jid, compare: (k1: string, k2: string) => k2.localeCompare (k1) }) export const waMessageKey = { @@ -139,7 +139,7 @@ export function generateClientID() { } // generate a random 16 byte ID to attach to a message export function generateMessageID() { - return randomBytes(16).toString('hex').toUpperCase() + return '3EB0' + randomBytes(4).toString('hex').toUpperCase() } export function decryptWA (message: string | Buffer, macKey: Buffer, encKey: Buffer, decoder: Decoder, fromMe: boolean=false): [string, Object, [number, number]?] { let commaIndex = message.indexOf(',') // all whatsapp messages have a tag and a comma, followed by the actual message