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 +}