support mesasge input from lid

This commit is contained in:
Rajeh Taher
2023-10-01 14:40:40 +00:00
parent 6f08d55bb7
commit ef8d1a09fb
2 changed files with 7 additions and 3 deletions

View File

@@ -655,6 +655,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
const { fullMessage: msg, category, author, decrypt } = decryptMessageNode( const { fullMessage: msg, category, author, decrypt } = decryptMessageNode(
node, node,
authState.creds.me!.id, authState.creds.me!.id,
authState.creds.me!.lid || '',
signalRepository, signalRepository,
logger, logger,
) )

View File

@@ -15,7 +15,8 @@ type MessageType = 'chat' | 'peer_broadcast' | 'other_broadcast' | 'group' | 'di
*/ */
export function decodeMessageNode( export function decodeMessageNode(
stanza: BinaryNode, stanza: BinaryNode,
meId: string meId: string,
meLid: string
) { ) {
let msgType: MessageType let msgType: MessageType
let chatId: string let chatId: string
@@ -27,6 +28,7 @@ export function decodeMessageNode(
const recipient: string | undefined = stanza.attrs.recipient const recipient: string | undefined = stanza.attrs.recipient
const isMe = (jid: string) => areJidsSameUser(jid, meId) const isMe = (jid: string) => areJidsSameUser(jid, meId)
const isMeLid = (jid: string) => areJidsSameUser(jid, meLid)
if(isJidUser(from)) { if(isJidUser(from)) {
if(recipient) { if(recipient) {
@@ -43,7 +45,7 @@ export function decodeMessageNode(
author = from author = from
} else if(isLidUser(from)) { } else if(isLidUser(from)) {
if(recipient) { if(recipient) {
if(!isMe(from)) { if(!isMeLid(from)) {
throw new Boom('receipient present, but msg not from me', { data: stanza }) throw new Boom('receipient present, but msg not from me', { data: stanza })
} }
@@ -111,10 +113,11 @@ export function decodeMessageNode(
export const decryptMessageNode = ( export const decryptMessageNode = (
stanza: BinaryNode, stanza: BinaryNode,
meId: string, meId: string,
meLid: string,
repository: SignalRepository, repository: SignalRepository,
logger: Logger logger: Logger
) => { ) => {
const { fullMessage, author, sender } = decodeMessageNode(stanza, meId) const { fullMessage, author, sender } = decodeMessageNode(stanza, meId, meLid)
return { return {
fullMessage, fullMessage,
category: stanza.attrs.category, category: stanza.attrs.category,