Skip to content

feat(appmsg): 支持合并聊天记录与文件消息解析#24

Open
hqhq1025 wants to merge 1 commit intojackwener:mainfrom
hqhq1025:codex/appmsg-record-file
Open

feat(appmsg): 支持合并聊天记录与文件消息解析#24
hqhq1025 wants to merge 1 commit intojackwener:mainfrom
hqhq1025:codex/appmsg-record-file

Conversation

@hqhq1025
Copy link
Copy Markdown

@hqhq1025 hqhq1025 commented May 1, 2026

Related to #22

背景

当前 wx history / wx search 对 WeChat appmsgbase type = 49)的处理比较粗:

  • type=19 的合并聊天记录会退化成普通链接标题
  • type=6 的文件消息只显示标题,缺少文件大小 / 扩展名等信息
  • --type link|file 的 SQL 过滤直接比较 local_type = 49,会漏掉大量 WeChat 4.x 的真实 appmsg 行,因为这类消息经常把 subtype 编进高 32 位,例如 19<<32 | 4957<<32 | 49

实际本地数据里,这会直接影响历史查询、搜索结果,以及对刚发送消息的验证体验。例如最新发到文件传输助手的合并聊天记录,在旧逻辑里会显示成 [链接] ...

改动

  • src/daemon/query.rs 中把 appmsg 解析改成 DOM-first:
    • type=19:解析 recorditem 里的 CDATA / 内嵌 XML,输出合并聊天记录摘要
    • type=6:解析 appattach,补充文件大小 / 扩展名 / md5
    • type=57:保留引用消息解析,并复用新的递归逻辑
  • history / search--type 过滤改为按低 32 位 base type 比较,避免 19<<32 | 49 / 57<<32 | 49 这类消息被漏掉
  • 新增回归测试:
    • 合并聊天记录样例解析
    • 文件消息元信息解析
    • query_messages 对高位 subtype 的过滤行为
  • 新增本地 #[ignore] 真实数据 probe,方便后续在开发机上继续回归验证
  • 把这次确认下来的 WeChat 4.x appmsg 解析坑和本地验证坑补充到 CLAUDE.md

兼容性

  • appmsg 消息行为不变
  • type 字段仍保持现有语义,表示底层 base type;本 PR 主要改善 content 的可读性和 --type 的过滤正确性
  • appmsg 解析仍保留 legacy string fallback,避免坏 XML 直接把整条消息打空
  • 不新增依赖,继续复用现有的 roxmltree

验证

项目级验证:

cargo check
cargo test appmsg_tests -- --nocapture

本地真实数据验证(ignored tests,使用 ~/.wx-cli/cache,不把真实消息内容写入仓库):

cargo test local_real_appmsg_probe -- --ignored --nocapture
cargo test local_latest_filehelper_base49_probe -- --ignored --nocapture
cargo test local_latest_filehelper_merged_record_probe -- --ignored --nocapture

结果:

  • 本地缓存中扫到 27036 条 base-49 appmsg,解析成功 26784
  • 其中包含 1370type=6 文件消息、558type=19 合并聊天记录、6517type=57 引用消息
  • 文件传输助手里最新一条合并聊天记录(19<<32 | 49)已能正确解析成多条聊天摘要,不再显示成普通链接标题

未跑完整 cross-target check:当前 macOS 本机缺 Linux / Windows 对应 C 交叉工具链,zstd-sys / libsqlite3-sys 会在工具链层面失败。本 PR 没有新增平台分支或 C 依赖。

@hqhq1025 hqhq1025 changed the title fix: parse appmsg subtypes from type 49 messages feat(appmsg): 支持合并聊天记录与文件消息解析 May 1, 2026
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.

1 participant