mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: cleanMessage for reaction messages
This commit is contained in:
@@ -505,7 +505,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
await sendReceipt(msg.key.remoteJid!, participant, [msg.key.id!], type)
|
await sendReceipt(msg.key.remoteJid!, participant, [msg.key.id!], type)
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanMessage(msg)
|
cleanMessage(msg, authState.creds.me!.id)
|
||||||
ev.emit('messages.upsert', { messages: [msg], type: stanza.attrs.offline ? 'append' : 'notify' })
|
ev.emit('messages.upsert', { messages: [msg], type: stanza.attrs.offline ? 'append' : 'notify' })
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -22,16 +22,17 @@ const MSG_MISSED_CALL_TYPES = new Set([
|
|||||||
])
|
])
|
||||||
|
|
||||||
/** Cleans a received message to further processing */
|
/** Cleans a received message to further processing */
|
||||||
export const cleanMessage = (message: proto.IWebMessageInfo) => {
|
export const cleanMessage = (message: proto.IWebMessageInfo, meId: string) => {
|
||||||
// ensure remoteJid doesn't have device or agent in it
|
// ensure remoteJid doesn't have device or agent in it
|
||||||
message.key.remoteJid = jidNormalizedUser(message.key.remoteJid!)
|
message.key.remoteJid = jidNormalizedUser(message.key.remoteJid!)
|
||||||
const content = normalizeMessageContent(message.message)
|
const content = normalizeMessageContent(message.message)
|
||||||
if(content) {
|
// if the message has a reaction, ensure fromMe & remoteJid are from our perspective
|
||||||
// if the message has a reaction, ensure fromMe & remoteJid are from our perspective
|
if(content?.reactionMessage) {
|
||||||
const msgKey = content.reactionMessage!.key!
|
const msgKey = content.reactionMessage.key!
|
||||||
if(!message.key.fromMe) {
|
if(!message.key.fromMe) {
|
||||||
|
msgKey.fromMe = areJidsSameUser(msgKey.participant || msgKey.remoteJid, meId)
|
||||||
msgKey.remoteJid = message.key.remoteJid
|
msgKey.remoteJid = message.key.remoteJid
|
||||||
msgKey.fromMe = !msgKey.fromMe
|
msgKey.participant = msgKey.participant || message.key.participant
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user