fix(discord): suppress pairing reply in groups without @mention (#1091)#1092
fix(discord): suppress pairing reply in groups without @mention (#1091)#1092
Conversation
When `pairing` group policy is combined with `Require @mention`, the bot posted a pairing code in response to every group message because `checkGroupPolicy` ran before the mention gate. Pre-compute the mention flag and pass it into `checkGroupPolicy`. When RequireMention is enabled and the bot was not addressed, return silently instead of triggering `sendPairingReply`. DMs are unchanged — every DM is implicitly directed at the bot. Fixes #1091
🔍 Code Review — fix(discord): suppress pairing reply in groups without @mention (#1091)🎯 Tổng quanHotfix: Discord channels với Scope: 1 file, +25/-15, 1 commit 🤖 CI Status + Merge ConflictsCI: ✅ All checks passed — go: pass (7m18s), web: pass (46s) ✅ Điểm Tốt
🟢 LOW (Nit)
📊 Summary
💡 Recommendation🟢 APPROVED Hotfix nhỏ, clean, đúng root cause, không side effects. Code refactor dedup mention check — improvement chứ không chỉ là band-aid fix. Ready to merge! 🚀 |
Summary
Hotfix for #1091. Discord channels with
pairinggroup policy +Require @mention in groupsenabled were spamming pairing codes on every group message.Root cause:
handleMessagecalledcheckGroupPolicy(which firessendPairingReplyonPolicyNeedsPairing) before the mention gate ran, so the pairing reply bypassed the mention requirement.Fix: Pre-compute the
mentionedflag once at the top ofhandleMessage, pass it intocheckGroupPolicy, and skipsendPairingReplywhenRequireMention()is enabled and the bot was not addressed. The existing mention gate later in the function reuses the same flag (deduped).DMs are intentionally unchanged — every DM is implicitly directed at the bot, so
checkDMPolicykeeps its current pairing-reply behavior.Behavior after fix
require_mention=truerequire_mention=falseTest plan
go build ./...(PG)go build -tags sqliteonly ./...(Desktop)go vet ./internal/channels/discord/...go test ./internal/channels/discord/...pairing+require_mention=true, send message without mention → bot stays silentFixes #1091