feat(platforms): add require_mention + allowed_users gating to DingTalk#9367
feat(platforms): add require_mention + allowed_users gating to DingTalk#9367yule975 wants to merge 1 commit into
Conversation
DingTalk was the only messaging platform without group-mention gating or a per-user allowlist. Slack, Telegram, Discord, WhatsApp, Matrix, and Mattermost all support these via config.yaml + matching env vars; this change closes the gap for DingTalk using the same surface: Config: platforms.dingtalk.require_mention: bool (env: DINGTALK_REQUIRE_MENTION) platforms.dingtalk.mention_patterns: list (env: DINGTALK_MENTION_PATTERNS) platforms.dingtalk.free_response_chats: list (env: DINGTALK_FREE_RESPONSE_CHATS) platforms.dingtalk.allowed_users: list (env: DINGTALK_ALLOWED_USERS) Semantics mirror Telegram's implementation: - DMs are always accepted (subject to allowed_users). - Group messages are accepted only when the chat is allowlisted, mention is not required, the bot was @mentioned (dingtalk_stream sets is_in_at_list), or the text matches a configured regex wake-word. - allowed_users matches sender_id / sender_staff_id case-insensitively; a single "*" disables the check. Rationale: without this, any DingTalk user in a group chat can trigger the bot, which makes DingTalk less safe to deploy than the other platforms. A user's config.yaml already accepts require_mention for dingtalk but the value was silently ignored.
|
Merged via #11564 (#11564). Your commit was cherry-picked with authorship preserved (9039273). Thanks for closing the DingTalk parity gap — the Telegram-mirroring semantics and config.yaml → env var bridge were exactly the right shape. Added 16 regression tests on top covering One small footnote: while writing tests I noticed the env-var fallback in |
Summary
DingTalk was the only messaging platform without group-mention gating or a per-user allowlist. Slack, Telegram, Discord, WhatsApp, Matrix, and Mattermost all expose these knobs via `config.yaml` + matching env vars; this change closes the gap for DingTalk using the same surface.
Config surface
```yaml
platforms:
dingtalk:
enabled: true
require_mention: true # env: DINGTALK_REQUIRE_MENTION
mention_patterns: # env: DINGTALK_MENTION_PATTERNS (JSON array)
- "^hermes"
free_response_chats: # env: DINGTALK_FREE_RESPONSE_CHATS (csv)
- "cidABC=="
allowed_users: # env: DINGTALK_ALLOWED_USERS (csv)
- "staff_1234"
```
Semantics (mirrors Telegram)
Rationale
Without this, any DingTalk user in a group chat can trigger the bot, which makes DingTalk less safe to deploy than the other platforms. A user's `config.yaml` today already accepts `require_mention` for dingtalk (the yaml loader silently lets it pass), but the value was ignored by the adapter.
Test plan
Files changed
No behaviour change when the new config keys are absent (opt-in).