From e15d2ffe3039670f9c8ea1ed01ab341e6b55e27e Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Sat, 30 Sep 2023 21:29:40 +0300 Subject: [PATCH] Update decode-wa-message.ts --- src/Utils/decode-wa-message.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Utils/decode-wa-message.ts b/src/Utils/decode-wa-message.ts index ebec0de..e74f89b 100644 --- a/src/Utils/decode-wa-message.ts +++ b/src/Utils/decode-wa-message.ts @@ -2,7 +2,7 @@ import { Boom } from '@hapi/boom' import { Logger } from 'pino' import { proto } from '../../WAProto' import { SignalRepository, WAMessageKey } from '../Types' -import { areJidsSameUser, BinaryNode, isJidBroadcast, isJidGroup, isJidStatusBroadcast, isJidUser } from '../WABinary' +import { areJidsSameUser, BinaryNode, isJidBroadcast, isJidGroup, isJidStatusBroadcast, isJidUser, isLidUser } from '../WABinary' import { unpadRandomMax16 } from './generics' const NO_MESSAGE_FOUND_ERROR_TEXT = 'Message absent from node' @@ -39,6 +39,19 @@ export function decodeMessageNode( chatId = from } + msgType = 'chat' + author = from + } else if (isLidUser(from)) { + if(recipient) { + if(!isMe(from)) { + throw new Boom('receipient present, but msg not from me', { data: stanza }) + } + + chatId = recipient + } else { + chatId = from + } + msgType = 'chat' author = from } else if(isJidGroup(from)) { @@ -183,4 +196,4 @@ export const decryptMessageNode = ( } } } -} \ No newline at end of file +}