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(
node,
authState.creds.me!.id,
authState.creds.me!.lid || '',
signalRepository,
logger,
)

View File

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