fix(worker): reactorJid null guard, document reaction removal, restore comments
This commit is contained in:
@@ -22,7 +22,9 @@ export function normalizeMessage(
|
||||
if (!key) return null;
|
||||
|
||||
const remoteJid = key.remoteJid ?? '';
|
||||
// only group messages (group JIDs end with @g.us)
|
||||
if (!remoteJid.endsWith('@g.us')) return null;
|
||||
// skip our own outgoing messages
|
||||
if (key.fromMe) return null;
|
||||
if (!msg.message) return null;
|
||||
|
||||
@@ -49,7 +51,9 @@ export function normalizeReaction(
|
||||
if (!key) return null;
|
||||
|
||||
const remoteJid = key.remoteJid ?? '';
|
||||
// only group messages (group JIDs end with @g.us)
|
||||
if (!remoteJid.endsWith('@g.us')) return null;
|
||||
// skip our own outgoing messages
|
||||
if (key.fromMe) return null;
|
||||
|
||||
const reaction = msg.message?.reactionMessage;
|
||||
@@ -58,10 +62,15 @@ export function normalizeReaction(
|
||||
const targetMsgId = reaction.key?.id;
|
||||
if (!targetMsgId) return null;
|
||||
|
||||
// Ensure reactorJid is not empty (group message must have a participant)
|
||||
const reactorJid = key.participant;
|
||||
if (!reactorJid) return null;
|
||||
|
||||
return {
|
||||
reactorJid: key.participant ?? '',
|
||||
reactorJid,
|
||||
targetMsgId,
|
||||
sourceGroupJid: remoteJid,
|
||||
// emoji is empty string ('') when reaction was removed (retraction)
|
||||
emoji: reaction.text ?? '',
|
||||
accountId,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user