Skip to content

feat(normalize): render post attachment zone in convertPost - #18

Open
yjhcjykwbk-jlsec wants to merge 1 commit into
larksuite:mainfrom
yjhcjykwbk-jlsec:feat/post-attachment-zone
Open

feat(normalize): render post attachment zone in convertPost#18
yjhcjykwbk-jlsec wants to merge 1 commit into
larksuite:mainfrom
yjhcjykwbk-jlsec:feat/post-attachment-zone

Conversation

@yjhcjykwbk-jlsec

Copy link
Copy Markdown

Summary

The rich-text attachment zone (top-level files array on a post message) was ignored by convertPost: only the locale document (title/content/content_v2) was flattened and scanned for resources, so attachments attached to a rich-text message were invisible to channel consumers (agents/CLIs).

This PR makes the attachment zone visible and downloadable:

  • src/normalize/converters/post.ts
    • topLevelAttachments(): extract the top-level files: [{file_key, file_name, is_folder}] array
    • render attachment-zone entries as <file key="..." name="..."/> / <folder key="..." name="..."/> lines after the body, matching the standalone file/folder converters
    • surface attachment-zone files as ResourceDescriptor(type: 'file') so they are downloadable; folders stay tag-only (mirrors the standalone folder converter's resources: [])
  • src/normalize/__tests__/converters.test.ts: two new tests — rendering + resource extraction, and empty files array tolerance

Wire shape

{
  "zh_cn": { "title": "报告", "content": [...] },
  "files": [
    { "file_key": "file_a", "file_name": "report.pdf" },
    { "file_key": "dir_1", "file_name": "assets", "is_folder": true }
  ]
}

renders as:

**报告**
正文
<file key="file_a" name="report.pdf"/>
<folder key="dir_1" name="assets"/>

with resources: [{type: 'file', fileKey: 'file_a', fileName: 'report.pdf'}].

Test

pnpm test   # 548 passed
pnpm typecheck  # clean

The rich-text attachment zone (top-level files array) was ignored by the
post converter: only the locale document (title/content) was flattened
and scanned for resources, so attachments attached to a rich-text message
were invisible to channel consumers.

- render attachment-zone files as <file key=... name=.../> lines and
  is_folder entries as <folder .../> lines, matching the standalone
  file/folder converters
- surface attachment-zone files as ResourceDescriptor(type=file) so they
  are downloadable; folders remain tag-only like the folder converter
- cover with tests: rendering + resource extraction, empty files array
@yjhcjykwbk-jlsec
yjhcjykwbk-jlsec force-pushed the feat/post-attachment-zone branch from e4d7480 to aa84321 Compare August 31, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants