fix(whatsapp): record channel activity only after access control passes for reactions

This commit is contained in:
saketkintali 2026-03-15 15:45:21 -07:00
parent f1d5a70223
commit 631d1ff833
1 changed files with 8 additions and 6 deletions

View File

@ -466,12 +466,6 @@ export async function monitorWebInbox(options: {
if (!resolvedFrom) continue;
const from = resolvedFrom;
recordChannelActivity({
channel: "whatsapp",
accountId: options.accountId,
direction: "inbound",
});
// Derive isFromMe from reactor identity, not key.fromMe.
// key.fromMe on a reaction refers to whether the *reacted-to message* was from us,
// not whether the reactor is us. Compare JIDs directly instead.
@ -497,6 +491,14 @@ export async function monitorWebInbox(options: {
});
if (!access.allowed) continue;
// Only record activity for reactions that pass access control — consistent with
// handleMessagesUpsert and prevents blocked/self reactions from inflating inbound metrics.
recordChannelActivity({
channel: "whatsapp",
accountId: options.accountId,
direction: "inbound",
});
const reactedMessageId = key?.id ?? undefined;
const chatJid = remoteJid;