|
|
|
|
@ -108,12 +108,14 @@ export const ResponseQueue = {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Encolar una reacción con idempotencia (24h) usando metadata canónica
|
|
|
|
|
async enqueueReaction(chatId: string, messageId: string, emoji: string): Promise<void> {
|
|
|
|
|
async enqueueReaction(chatId: string, messageId: string, emoji: string, opts?: { participant?: string; fromMe?: boolean }): Promise<void> {
|
|
|
|
|
try {
|
|
|
|
|
if (!chatId || !messageId || !emoji) return;
|
|
|
|
|
|
|
|
|
|
// Construir JSON canónico
|
|
|
|
|
const metaObj = { kind: 'reaction', emoji, chatId, messageId };
|
|
|
|
|
// Construir JSON canónico (incluir participant/fromMe si están disponibles)
|
|
|
|
|
const metaObj: any = { kind: 'reaction', emoji, chatId, messageId };
|
|
|
|
|
if (typeof opts?.fromMe === 'boolean') metaObj.fromMe = !!opts.fromMe;
|
|
|
|
|
if (opts?.participant) metaObj.participant = opts.participant;
|
|
|
|
|
const metadata = JSON.stringify(metaObj);
|
|
|
|
|
const emojiLabel = emoji === '✅' ? 'check' : (emoji === '🤖' ? 'robot' : (emoji === '⚠️' ? 'warn' : 'other'));
|
|
|
|
|
|
|
|
|
|
@ -173,8 +175,13 @@ export const ResponseQueue = {
|
|
|
|
|
if (!chatId || !messageId || !emoji) {
|
|
|
|
|
return { ok: false, error: 'invalid_reaction_metadata' };
|
|
|
|
|
}
|
|
|
|
|
const fromMe = !!meta.fromMe;
|
|
|
|
|
const key: any = { remoteJid: chatId, fromMe, id: messageId };
|
|
|
|
|
if (meta.participant) {
|
|
|
|
|
key.participant = String(meta.participant);
|
|
|
|
|
}
|
|
|
|
|
const payload = {
|
|
|
|
|
key: { remoteJid: chatId, fromMe: false, id: messageId },
|
|
|
|
|
key,
|
|
|
|
|
reaction: emoji
|
|
|
|
|
};
|
|
|
|
|
try {
|
|
|
|
|
|