Skip to content

feat: merge Feishu/Lark into unified adapter with region toggle#329

Open
pluginmd wants to merge 1 commit intoRightNow-AI:mainfrom
pluginmd:feat/feishu-lark-merge
Open

feat: merge Feishu/Lark into unified adapter with region toggle#329
pluginmd wants to merge 1 commit intoRightNow-AI:mainfrom
pluginmd:feat/feishu-lark-merge

Conversation

@pluginmd
Copy link

@pluginmd pluginmd commented Mar 5, 2026

Summary

Merge lark.rs into feishu.rs — one unified adapter with region toggle instead of two separate channels.

Why?

Feishu (飞书) and Lark are the same product by ByteDance, just different regions:

Feishu (CN domestic) Lark (International)
Domain open.feishu.cn open.larksuite.com
Market China mainland Global (SEA, JP, US, EU…)
API Identical endpoints & schemas Identical endpoints & schemas
Auth Same tenant_access_token flow Same tenant_access_token flow
Events Same V2 webhook callback format Same V2 webhook callback format

The only difference is the base URL domain. Maintaining two separate adapters (feishu.rs + lark.rs) was redundant — same code, different domain string.

What changed

Single [channels.feishu] config with region field ("cn" or "intl") controls which API domain is used:

  • region = "cn"open.feishu.cn (Feishu domestic, default)
  • region = "intl"open.larksuite.com (Lark international)

Features merged from lark.rs into feishu.rs

  • Event decryption — AES-256-CBC decrypt for encrypted webhook payloads
  • Message dedup — Ring-buffer cache preventing duplicate message processing
  • Event dedup — Separate ring-buffer for event_id deduplication
  • Group chat filtering — Only respond when @mentioned, question mark, or bot name detected
  • Rich text parsing — Extract text from post (rich text) messages with locale fallback
  • @mention stripping — Clean @_user_1 placeholders from message text

Changes

File What
crates/openfang-channels/src/feishu.rs Complete rewrite — merged all lark.rs features, added FeishuRegion enum with domain switching
crates/openfang-types/src/config.rs Expanded FeishuConfig: +5 fields (region, webhook_path, verification_token, encrypt_key_env, bot_names)
crates/openfang-api/src/channel_bridge.rs Updated wiring to pass all new config fields to FeishuAdapter::with_config()
crates/openfang-api/src/routes.rs Updated ChannelMeta UI — region as basic field, 6 new advanced fields

Config example

[channels.feishu]
app_id = "cli_abc123"
app_secret_env = "FEISHU_APP_SECRET"
region = "cn"                          # "cn" = Feishu, "intl" = Lark
# webhook_port = 8453
# webhook_path = "/feishu/webhook"
# verification_token = "your-verify-token"
# encrypt_key_env = "FEISHU_ENCRYPT_KEY"
# bot_names = ["MyBot", "Assistant"]

Test plan

  • cargo build --workspace --lib — compiles
  • cargo test --workspace — all tests pass
  • cargo clippy -p openfang-channels -p openfang-api -p openfang-types -- -D warnings — zero warnings
  • Live server: /api/channels returns all 9 Feishu fields correctly
  • Manual: configure with real Feishu CN credentials
  • Manual: configure with real Lark International credentials

🤖 Generated with Claude Code

Merge lark.rs features (dedup, encryption, group filtering, rich text parsing)
into feishu.rs with FeishuRegion toggle (cn/intl). Single [channels.feishu]
config handles both domestic Feishu and international Lark via region field.

- Expand FeishuConfig: region, webhook_path, verification_token, encrypt_key_env, bot_names
- Add FeishuRegion enum with domain switching (open.feishu.cn / open.larksuite.com)
- Add AES-256-CBC event decryption, message/event dedup, group chat filtering
- Update channel_bridge.rs wiring for full config
- Update routes.rs ChannelMeta with new UI fields (region basic, rest advanced)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@jaberjaber23 jaberjaber23 added the under-review PR is under review label Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

under-review PR is under review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants