← Back to PRs

#21781: feat(feishu): resolve merge_forward, enrich quoted message parsing, add media type support

by laopuhuluwa open 2026-02-20 10:51 View on GitHub →
channel: feishu size: L
## Summary Enhance the Feishu plugin with three key capabilities: merge_forward message resolution, enriched quoted message parsing, and media type support. ## Changes ### bot.ts #### merge_forward Resolution - New `resolveMergeForwardContent()`: fetches sub-messages from merge_forward containers via `im.message.get` API - Extracts text, images, and downloadable media from each sub-message - Handles nested message types (text, post, image, video, media, file, interactive) - Downloads media using **original file_keys** from sub-messages (not placeholder keys from the forwarded container, which return 400) #### Enhanced `parsePostContent()` - Now extracts embedded `<media>` tags (video/audio files in rich text) alongside images - Returns `mediaKeys` array and `mentionedOpenIds` for downstream use - Embedded media is downloaded and attached as inbound media #### Media Type Support - Added `"media"` to the mediaTypes whitelist in `resolveFeishuMediaList` - Fixed fileKey priority: video/media types now prefer `fileKey` (actual content) over `imageKey` (thumbnail) #### ReplyToId Exposure - Dispatch envelope now includes `ReplyToId: ctx.parentId` so agents can trace quoted message chains - Enables agent-level content recovery (e.g., searching session logs by message_id) ### send.ts #### Enriched `getMessageFeishu()` - **Post messages**: parses rich text elements (text, links, mentions, images, media tags) into readable text - **Interactive (card) messages**: extracts text from card elements (`text`/`lark_md`/`md`/`markdown` tags), falls back to degraded post format - Previously only handled `text` type, returning raw JSON for all others ## Usage ### merge_forward Automatic: when a user forwards merged messages to the bot, sub-messages are expanded inline with sender info and timestamps. ### Quoted Messages When a user replies to a message: 1. **Text messages**: gateway resolves content directly via `getMessageFeishu` ✅ 2. **Card (interactive) messages**: gateway returns best-effort degraded text; agent can use `ReplyToId` to trace the quote chain via `im.message.get` API and recover full content from session logs 3. **Post (rich text) messages**: gateway now parses all element types including embedded media ### Media in Posts Embedded videos/audio in rich text messages are now automatically downloaded and attached as media, alongside embedded images. ## Testing - Tested merge_forward with 4+ sub-messages (text, post, interactive mix) - Tested quoted message parsing for text, interactive, and post types - Tested embedded media extraction from post messages - Build passes, lint clean (0 warnings, 0 errors)

Most Similar PRs