feat(gateway): Phase 3 quick fixes — bot filter, fallback, logging, docs#1173
Merged
Conversation
added 2 commits
June 22, 2026 02:50
…t logging - Add GATEWAY_ALLOW_BOT_MESSAGES / GATEWAY_TRUSTED_BOT_IDS env vars to process_gateway_event(). Bot messages are now passthrough when explicitly allowed or sender is in trusted list. (Issue #1172 task 1) - Send user-facing fallback message when create_thread fails instead of silently falling back to channel. (Issue #1172 task 6) - Log warning when attachment has neither path nor data. (Issue #1172 task 7)
Documents all GATEWAY_* env vars including security gating (ALLOW_ALL_CHANNELS/USERS defaults, ALLOW_BOT_MESSAGES, TRUSTED_BOT_IDS) with production checklist warning. Issue #1172 task 5.
This comment has been minimized.
This comment has been minimized.
added 4 commits
June 22, 2026 03:00
Initialize GoogleChatAdapter with SA key parsing, access token, and JWT verifier from env vars (same as standalone gateway). Register /webhook/googlechat route. Removes the TODO placeholder (google_chat: None). Issue #1172 task 2.
Both process_gateway_event() and run_gateway_adapter() now call should_skip_event() for bot filtering, channel/user allowlist, and @mention gating. Eliminates ~30 lines of duplicated filter logic. Also brings bot_messages/trusted_bot_ids support to the WebSocket path (previously hardcoded to drop all bots). Issue #1172 task 3 (partial — filter logic deduped, attachment processing dedup deferred).
Add AppState::from_env(event_tx, ws_token) factory method to the gateway crate. Unified mode in main.rs now calls this single method instead of inline-constructing AppState (~60 lines → 1 line). This eliminates config divergence risk between unified and standalone modes — both paths now share the same adapter initialization logic. The standalone serve() function will be migrated to use from_env() in a follow-up (its feishu_ws_mode inspection makes it slightly more involved). Issue #1172 task 4.
GatewayParams uses Vec<String> for allowed_channels/allowed_users. Convert once at run_gateway_adapter start rather than per-event.
This comment has been minimized.
This comment has been minimized.
- Remove empty line between doc comment and function - Change EventFilterParams/should_skip_event from pub(crate) to module-private (GatewayEvent is private)
This comment has been minimized.
This comment has been minimized.
…allback - F1: Remove per-event empty_set allocation in WS loop; use hoisted trusted_bot_ids from GatewayParams - F2: Add allow_bot_messages/trusted_bot_ids to GatewayParams and GatewayConfig so WS path respects the same env vars as unified mode - F3: Replace silent let _ with tracing::warn on fallback send_message failure in both WS and unified code paths
Move loop-invariant EventFilterParams construction from per-event match arm to before the inner loop. All referenced variables (allowed_channels, allowed_users, trusted_bot_ids, bot_username) are declared before the outer reconnect loop and outlive the filter.
…t filter log - Empty string env var no longer fails open (was: "" != "0" → true) - Add tracing::info when bot is filtered, matching channel/user filter observability
This comment has been minimized.
This comment has been minimized.
- Add 8 unit tests for should_skip_event() covering all filter branches - Document allow_bot_messages/trusted_bot_ids in [gateway] config section (note: bool type, not AllowBots enum like Discord/Slack) - Fix prefix-less env var names in config-reference Security Gating - Add missing Google Chat env vars (SA_KEY_FILE, ACCESS_TOKEN, WEBHOOK_PATH) - Log warning when GOOGLE_CHAT_SA_KEY_FILE read fails (both paths) - Document that Google Chat JWT is optional when AUDIENCE unset
…k logging - F4: Add doc comment on GatewayConfig.allow_bot_messages explaining intentional bool vs AllowBots difference (mention gating handled by bot_username + should_skip_event separately) - F10: Remove separate fallback warning send_message that preceded the actual reply on ordered-delivery platforms (Telegram/LINE). The create_thread failure is still logged server-side. - F11: Add tracing::warn for image/text_file read failures in webhook path, matching the WS path behavior. - F9: Already addressed — CI has cargo clippy --features unified.
This comment has been minimized.
This comment has been minimized.
Collaborator
Author
|
LGTM ✅ — Bot filter, dedup refactor, factory extraction, and docs all well-implemented with comprehensive tests. What This PR DoesImplements all 7 follow-up tasks from Phase 3 unified webhook integration (#1172): configurable bot filtering with trusted-bot bypass, Google Chat wiring in unified mode, filter logic deduplication, How It Works
Findings
Baseline Check
What's Good (🟢)
CI: ✅ All checks green | HEAD: |
thepagent
approved these changes
Jun 22, 2026
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements all 7 tasks from #1172 (Phase 3 unified webhook follow-ups):
GATEWAY_ALLOW_BOT_MESSAGES/GATEWAY_TRUSTED_BOT_IDSenv — Bot messages pass through when allowed or sender is trusted.should_skip_event()helper shared by both code paths.AppState::from_env()factory — Unified mode goes from 60-line inline construction to single method call. Eliminates config divergence.docs/config-reference.mdunified mode table.create_threadfails — "tracing::warnwith filename/mime.Related