feat(feishu): add support for merge_forward message parsing#28707
feat(feishu): add support for merge_forward message parsing#28707Takhoffman merged 2 commits intoopenclaw:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e03338e18d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
|
|
||
| // Filter to only sub-messages (those with upper_message_id, skip the merge_forward container itself) | ||
| const subMessages = items.filter((item) => item.upper_message_id); |
There was a problem hiding this comment.
Restrict merge-forward expansion to direct child items
The current filter keeps every item with a truthy upper_message_id, which means nested descendants are treated as top-level entries whenever Feishu returns recursive items for nested merge_forward content. In that case, grandchildren from nested forwards are expanded as regular bullets (despite the "[Nested Merged Forward]" placeholder intent), producing duplicated or out-of-scope content; this should filter by the current container message id instead of any non-empty parent id.
Useful? React with 👍 / 👎.
Greptile SummaryAdded support for parsing Feishu Key changes:
Issues found:
Confidence Score: 4/5
Last reviewed commit: e03338e |
| path: { message_id: event.message.message_id }, | ||
| })) as { code?: number; data?: { items?: unknown[] } }; | ||
|
|
||
| if (response.code === 0 && response.data?.items && response.data.items.length > 0) { |
There was a problem hiding this comment.
Remove length > 0 check - causes misleading "could not fetch" error when API returns empty items array. parseMergeForwardContent already handles empty arrays correctly (returns "no sub-messages").
| if (response.code === 0 && response.data?.items && response.data.items.length > 0) { | |
| if (response.code === 0 && response.data?.items) { |
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/feishu/src/bot.ts
Line: 682
Comment:
Remove `length > 0` check - causes misleading "could not fetch" error when API returns empty items array. `parseMergeForwardContent` already handles empty arrays correctly (returns "no sub-messages").
```suggestion
if (response.code === 0 && response.data?.items) {
```
How can I resolve this? If you propose a fix, please make it concise.- Detect merge_forward message type in handleFeishuMessage() - Fetch sub-messages via im.message.get API (websocket event doesn't include them) - Parse and format sub-messages into readable text - Support text, post, image, file, audio, video, sticker message types - Limit to 50 sub-messages to prevent excessive API calls - Handle nested merge_forward as placeholder (no recursive expansion) Fixes: Feishu merged/forwarded messages now display actual content instead of just 'Merged and Forwarded Message' placeholder.
09da56d to
e23aeca
Compare
|
PR #28707 - feat(feishu): add support for merge_forward message parsing (#28707) Merged via squash.
Thanks @tsu-builds! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e23aeca69f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
|
|
||
| // Filter to only sub-messages (those with upper_message_id, skip the merge_forward container itself) | ||
| const subMessages = items.filter((item) => item.upper_message_id); |
There was a problem hiding this comment.
Filter merge-forward items by container message ID
items.filter((item) => item.upper_message_id) treats every descendant as a top-level sub-message, so when Feishu returns recursive items (for nested merged forwards or nested replies) grandchildren get flattened into this message body and can duplicate/out-of-scope content. This breaks the intended [Nested Merged Forward] boundary and can feed unrelated nested text to the agent; restrict the expansion to items whose upper_message_id matches the current merge-forward container message ID.
Useful? React with 👍 / 👎.
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]> (cherry picked from commit ed8e6f7)
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]> (cherry picked from commit ed8e6f7)
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]> (cherry picked from commit ed8e6f7)
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]> (cherry picked from commit f53ef73)
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]> (cherry picked from commit f53ef73)
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…#28707) thanks @tsu-builds Verified: - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]> (cherry picked from commit f53ef73)
…#28707) thanks @tsu-builds (#1461) Verified: - pnpm build - pnpm check - pnpm test:macmini (cherry picked from commit f53ef73) Co-authored-by: tsu-builds <[email protected]> Co-authored-by: tsu-builds <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
OpenClaw PR: Support Feishu merge_forward message parsing
Summary
This PR adds support for parsing Feishu
merge_forward(合并转发) messages. Previously, these messages would only show a placeholder text "Merged and Forwarded Message" without the actual content.Problem
When a user sends a merged/forwarded message in Feishu:
message.contentfield only contains the placeholder string"Merged and Forwarded Message"Solution
merge_forwardmessage type inhandleFeishuMessage()im.message.getAPI with the message_iditemsarray, withupper_message_idpointing to the merge_forward containerChanges
extensions/feishu/src/bot.tsModified
parseMessageContent(): Return a loading placeholder formerge_forwardtypeAdded
parseMergeForwardContent(): Async function to parse the API response and format sub-messagesAdded
formatSubMessageContent(): Helper to format individual sub-message content based on typeModified
handleFeishuMessage(): Added logic to fetch and expand merge_forward messages via APIExample Output
Before:
After:
Testing
Tested with real Feishu merge_forward messages containing:
Notes
[Nested Merged Forward](no recursive expansion)