fix(whatsapp): require participant field for group reactions

When reacting to WhatsApp group messages, the 'participant' field is
required by Baileys but was previously optional, leading to silent
failures where reactions appeared to succeed but were never sent.

This change adds validation to fail fast with a clear error message
when attempting to react to a group message without providing the
participant JID.

Fixes issue where reactions in WhatsApp groups returned {ok: true}
but were never delivered to WhatsApp servers.

Example error:
  WhatsApp group reactions require the 'participant' field (sender JID).
  Example: participant: '1234567890@s.whatsapp.net'
This commit is contained in:
Sir Dobby 2026-01-29 00:41:11 +07:00 committed by wpeterr
parent 9688454a30
commit 848ae569f2

View File

@ -255,17 +255,28 @@ export const whatsappPlugin: ChannelPlugin<ResolvedWhatsAppAccount> = {
const messageId = readStringParam(params, "messageId", {
required: true,
});
const chatJid =
readStringParam(params, "chatJid") ?? readStringParam(params, "to", { required: true });
const participant = readStringParam(params, "participant");
// Validate participant for group reactions
if (!participant && chatJid.endsWith("@g.us")) {
throw new Error(
"WhatsApp group reactions require the 'participant' field (sender JID). " +
"Example: participant: '1234567890@s.whatsapp.net'"
);
}
const emoji = readStringParam(params, "emoji", { allowEmpty: true });
const remove = typeof params.remove === "boolean" ? params.remove : undefined;
return await getWhatsAppRuntime().channel.whatsapp.handleWhatsAppAction(
{
action: "react",
chatJid:
readStringParam(params, "chatJid") ?? readStringParam(params, "to", { required: true }),
chatJid,
messageId,
emoji,
remove,
participant: readStringParam(params, "participant"),
participant: participant ?? undefined,
accountId: accountId ?? undefined,
fromMe: typeof params.fromMe === "boolean" ? params.fromMe : undefined,
},