mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
support mesasge input from lid
This commit is contained in:
@@ -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,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user