fix(unified): port reaction_add handler to unified build#1177
Conversation
The unified binary was missing the reaction_add EventHandler method, causing emoji reaction mappings to silently not work. This was never ported when the workspace restructure moved code to openab-core. Ported from src/discord.rs (v0.8.5) to crates/openab-core/src/discord.rs. Removed ctl_registry references (IPC not yet in unified). Fixes #1176
|
LGTM ✅ — Clean port of the What This PR DoesThe unified binary ( How It WorksPorts the full
Findings
Finding Details🟢 F1: Faithful port with correct gating parityThe handler replicates all access-control gates from 🟢 F2: Defense-in-depth bot re-checkAfter fetching user info via 🟢 F3: Multibot routingIn Baseline Check
What's Good (🟢)
|
F1: Only call bot_participated_in_thread when gating mode requires it
(Involved/MultibotMentions). Avoids unconditional API calls that
cause rate-limiting on non-thread channels.
F2: Move is_denied_user check into spawned task after to_user().await
confirms bot status, fixing premature gating with partial cache.
F3: Reuse detect_thread and build_sender_context helpers instead of
manual reimplementation, eliminating DRY violations.
F1: Move channel/thread detection + allowlist check BEFORE spawn and
BEFORE bot_participated_in_thread. Only call participation check
when is_thread=true AND gating mode requires it. Non-thread
channels and unallowed threads never trigger the 200-message API
fetch. No Arc<Mutex> refactoring needed.
F2: Move is_denied_user check into spawned task after to_user().await
confirms bot status, fixing premature gating with partial cache.
F3: Reuse detect_thread and build_sender_context helpers instead of
manual reimplementation, eliminating DRY violations.
6311390 to
8213774
Compare
…ng tests Extract reaction gating logic into a testable pure function and add 8 focused tests covering: - Mentions mode always rejects reactions - Non-thread channels skip participation check - Uninvolved thread rejected - Involved thread accepted - MultibotMentions single-bot thread accepted - MultibotMentions targets this bot accepted - MultibotMentions targets other bot rejected - MultibotMentions non-thread rejected This pins the gating ordering that regressed during review.
Problem
The unified binary (
Dockerfile.unified/pre-beta-*images) was missing thereaction_addEventHandler method. Emoji reaction mappings configured via[reactions.mapping]silently did nothing.Root Cause
When the workspace was restructured (PR #1146),
reaction_addwas never ported fromsrc/discord.rstocrates/openab-core/src/discord.rs.Fix
Ported the full
reaction_addhandler (~247 lines) from the standard build. Removedctl_registryreferences (IPC module not yet in unified — tracked separately).Testing
cargo check --features unified✅cargo clippy --features unified -- -D warnings✅Fixes #1176