diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index 54a5cc6..0c93de8 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -505,7 +505,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { 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' }) } ) diff --git a/src/Utils/process-message.ts b/src/Utils/process-message.ts index a0cf2ba..23a1d80 100644 --- a/src/Utils/process-message.ts +++ b/src/Utils/process-message.ts @@ -22,16 +22,17 @@ const MSG_MISSED_CALL_TYPES = new Set([ ]) /** 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 message.key.remoteJid = jidNormalizedUser(message.key.remoteJid!) const content = normalizeMessageContent(message.message) - if(content) { - // if the message has a reaction, ensure fromMe & remoteJid are from our perspective - const msgKey = content.reactionMessage!.key! + // if the message has a reaction, ensure fromMe & remoteJid are from our perspective + if(content?.reactionMessage) { + const msgKey = content.reactionMessage.key! if(!message.key.fromMe) { + msgKey.fromMe = areJidsSameUser(msgKey.participant || msgKey.remoteJid, meId) msgKey.remoteJid = message.key.remoteJid - msgKey.fromMe = !msgKey.fromMe + msgKey.participant = msgKey.participant || message.key.participant } } }