Fix: Agregar fromMe al key de reacciones para mensajes propios
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m11s
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m11s
This commit is contained in:
@@ -39,12 +39,13 @@ export default defineEventHandler(async (event) => {
|
|||||||
|
|
||||||
const rawMessage = msgResult.rows[0].raw_message
|
const rawMessage = msgResult.rows[0].raw_message
|
||||||
const jid = rawMessage?.key?.remoteJid
|
const jid = rawMessage?.key?.remoteJid
|
||||||
|
const fromMe = rawMessage?.key?.fromMe || false
|
||||||
|
|
||||||
if (!jid) {
|
if (!jid) {
|
||||||
throw createError({ statusCode: 400, message: 'Could not determine message JID' })
|
throw createError({ statusCode: 400, message: 'Could not determine message JID' })
|
||||||
}
|
}
|
||||||
|
|
||||||
await baileysManager.sendReaction(instanceId, jid, body.messageId, body.emoji)
|
await baileysManager.sendReaction(instanceId, jid, body.messageId, body.emoji, fromMe)
|
||||||
|
|
||||||
return { success: true, messageId: body.messageId, emoji: body.emoji }
|
return { success: true, messageId: body.messageId, emoji: body.emoji }
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|||||||
@@ -587,7 +587,7 @@ class BaileysManager extends EventEmitter {
|
|||||||
/**
|
/**
|
||||||
* Send a reaction to a message
|
* Send a reaction to a message
|
||||||
*/
|
*/
|
||||||
async sendReaction(instanceId: string, jid: string, messageId: string, emoji: string): Promise<void> {
|
async sendReaction(instanceId: string, jid: string, messageId: string, emoji: string, fromMe: boolean = false): Promise<void> {
|
||||||
const managed = this.instances.get(instanceId)
|
const managed = this.instances.get(instanceId)
|
||||||
if (!managed?.socket) {
|
if (!managed?.socket) {
|
||||||
throw new Error('Instance not connected')
|
throw new Error('Instance not connected')
|
||||||
@@ -598,11 +598,12 @@ class BaileysManager extends EventEmitter {
|
|||||||
text: emoji,
|
text: emoji,
|
||||||
key: {
|
key: {
|
||||||
remoteJid: jid,
|
remoteJid: jid,
|
||||||
id: messageId
|
id: messageId,
|
||||||
|
fromMe: fromMe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log(`[BaileysManager] Sent reaction ${emoji} to message ${messageId}`)
|
console.log(`[BaileysManager] Sent reaction ${emoji} to message ${messageId} (fromMe: ${fromMe})`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1094,12 +1094,13 @@ export async function handleToolCall(toolName: string, args: Record<string, any>
|
|||||||
|
|
||||||
const rawMessage = msgResult.rows[0].raw_message
|
const rawMessage = msgResult.rows[0].raw_message
|
||||||
const jid = rawMessage?.key?.remoteJid
|
const jid = rawMessage?.key?.remoteJid
|
||||||
|
const fromMe = rawMessage?.key?.fromMe || false
|
||||||
|
|
||||||
if (!jid) {
|
if (!jid) {
|
||||||
return mcpError('No se pudo determinar el JID del mensaje')
|
return mcpError('No se pudo determinar el JID del mensaje')
|
||||||
}
|
}
|
||||||
|
|
||||||
await baileysManager.sendReaction(instanceId, jid, messageId, emoji)
|
await baileysManager.sendReaction(instanceId, jid, messageId, emoji, fromMe)
|
||||||
|
|
||||||
return mcpSuccess({
|
return mcpSuccess({
|
||||||
ok: true,
|
ok: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user