feat(gateway): allowed_{channels,chats,rooms} whitelist — Slack (salvage #7401) + widening to Telegram/Mattermost/Matrix/DingTalk#21251
Merged
Conversation
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-import |
1 |
First entries
tests/gateway/test_allowed_channels_widening.py:17: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`
✅ Fixed issues: none
Unchanged: 3955 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
929c0bd to
49c5521
Compare
…am, Mattermost, Matrix, DingTalk Mirrors the Slack `allowed_channels` feature (PR #7401) and Discord's `allowed_channels` (PR #7044) across the remaining group-capable platforms. All five platforms (Slack + Discord + the four added here) now follow the same pattern: primary config via config.yaml, env-var fallback as an escape hatch — matching the project policy that .env is for secrets only and behavioral settings belong in config.yaml. Also fixes a duplicate `slack` key in DEFAULT_CONFIG introduced by PR #7401 (the later entry silently overwrote `allowed_channels`, `require_mention`, and `free_response_channels` at dict-literal evaluation time). Platforms added: - Telegram: `telegram.allowed_chats` (env alias: `TELEGRAM_ALLOWED_CHATS`) - Mattermost: `mattermost.allowed_channels` (env alias: `MATTERMOST_ALLOWED_CHANNELS`) - Matrix: `matrix.allowed_rooms` (env alias: `MATRIX_ALLOWED_ROOMS`) - DingTalk: `dingtalk.allowed_chats` (env alias: `DINGTALK_ALLOWED_CHATS`) Mattermost and Matrix previously had NO config.yaml bridging for any of their gating settings; this PR adds `load_gateway_config` bridges for them (Mattermost gets require_mention + free_response_channels + allowed_channels; Matrix gets allowed_rooms on top of its existing bridges for require_mention and free_response_rooms). Semantics identical everywhere: - Empty = no restriction (fully backward compatible). - Non-empty = hard whitelist: non-listed chats are silently ignored, even when the bot is @mentioned. - DMs bypass the check entirely. DEFAULT_CONFIG merges the duplicate `slack` block and adds new `mattermost` and `matrix` blocks so all gating settings surface in defaults. Not included: Feishu (has its own per-chat `chat_rules` system that covers this use case differently), WhatsApp (already has `group_allow_from` via `group_policy: allowlist`), pure-DM platforms (Signal, SMS, BlueBubbles, Yuanbao — no group concept).
49c5521 to
d0f10f4
Compare
19 tasks
1 task
4 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
Adds an
allowed_{channels,chats,rooms}whitelist to five gateway platforms. Salvages @CashWilliams's Slack PR #7401 onto current main, fixes a duplicate-key bug it introduced inDEFAULT_CONFIG, and widens the same pattern (already merged for Discord in #7044) to Telegram, Mattermost, Matrix, and DingTalk.All settings are config.yaml primary, env-var fallback — matching the project policy that
.envis for secrets only and behavioral settings belong inconfig.yaml.Platforms
slack.allowed_channelsSLACK_ALLOWED_CHANNELStelegram.allowed_chatsTELEGRAM_ALLOWED_CHATSmattermost.allowed_channelsMATTERMOST_ALLOWED_CHANNELSmatrix.allowed_roomsMATRIX_ALLOWED_ROOMSdingtalk.allowed_chatsDINGTALK_ALLOWED_CHATSdiscord.allowed_channelsDISCORD_ALLOWED_CHANNELSMattermost and Matrix previously had no config.yaml bridging at all for their gating settings; this PR adds
load_gateway_configbridges for them (Mattermost:require_mention+free_response_channels+allowed_channels; Matrix:allowed_roomson top of existing bridges forrequire_mentionandfree_response_rooms).Semantics (identical everywhere)
require_mention/free_response_*.Bugfix
PR #7401 added a new top-level
slackblock toDEFAULT_CONFIGwhile anotherslackblock (forchannel_prompts) already existed further down. Python dict literals silently drop the earlier key, soallowed_channels,require_mention, andfree_response_channelsnever made it intoDEFAULT_CONFIG. Merged into a single block.Example config.yaml
Not included
chat_rules) that already covers this differently.group_allow_fromviagroup_policy: allowlist.Validation
tests/gateway/test_slack_mention.py— 55/55 passedtests/gateway/test_allowed_channels_widening.py— 27/27 passedload_gateway_config()with all six YAML keys set → correct env vars populatedCredits