feat(group): 支持群昵称/群名片展示#23
Open
hqhq1025 wants to merge 1 commit intojackwener:mainfrom
Open
Conversation
Author
|
补一条本地真实数据验证,确认群昵称功能在 出于隐私原因,这里不贴真实群名、成员标识或群昵称,只保留验证方法和结论。 我在本机把群昵称分支和 appmsg 分支一起整合后,先 wx members "<group>" --json
wx history "<group>" --json -n 8对一个本地确实存在群昵称映射的活跃群做验证。 结果里:
也就是说,这条功能链本身是通的,之前的问题出在本地验证时复用了旧后台进程。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
微信群成员在不同群里经常会设置不同的群昵称/群名片。当前
wx members只从contact.nick_name/contact.remark生成display,群聊消息里的sender/last_sender/stats.top_senders也只会回退到联系人名或 username。实际使用时,这会让大群里的发言人很难对应到群内身份,比如同一个联系人在不同群里的展示名不同,或者联系人备注和群名片不是同一套命名规则。
改动
contact/contact.db的chat_room.ext_buffer解析群昵称,生成member_username -> group_nickname映射wx members --json每个成员新增/补齐:display:展示名,优先使用群昵称contact_display:联系人备注或微信昵称group_nickname:群昵称;本地没有记录时为空字符串is_owner:是否群主sender/last_sender/stats.top_senders优先使用群昵称,缺失时回退到联系人备注、微信昵称或 usernameREADME.md/SKILL.md同步说明群昵称显示规则和members输出字段实现要点
ext_buffer按 protobuf-like wire format 只读解析,支持 varint、fixed32、fixed64、length-delimited 字段跳过/提取chatroom_member里的当前成员 username 作为锚点,避免把其它字符串误判成成员 IDmembers主路径直接复用同一个contact.db连接读取chatroom_member和ext_buffersearch会批量加载涉及群聊的昵称表,并用Arc在各 DB 分组任务间共享,避免重复打开 contact.db 和深拷贝大 map兼容性
ext_buffer、没有群昵称,或解析不到稳定成员映射时,会回退到原来的联系人显示名/usernamemembers的display在有群昵称时会更贴近微信群内显示;需要旧联系人名语义的调用方可以读contact_displayusername/display/is_owner仍保留局限
chat_room.ext_buffer不是公开 schema,这里按本地数据和 protobuf-like 结构做了保守解析。为了降低误判,解析会用当前群成员 username 做锚点,并过滤控制字符、超长字符串和明显 username-like 的昵称候选。历史消息里如果 sender 已经不在当前
chatroom_member里,仍可能只能回退到联系人名或 username。这属于本地成员表快照和历史消息之间的天然差异。验证
项目级验证:
结果:43 个单测全过。新增 2 个群昵称解析单测,覆盖 protobuf-like member chunk 解析和 target username 锚定。
本地真实数据抽检,不输出真实群名/昵称/消息内容:
wx members,0 个命令失败、0 个 schema 异常、0 个 display 优先级异常、0 个空 displaygroup_nickname,93 个群有群昵称数据members/history/search/stats,绝大多数 sender 能落回当前members.display;少量不在成员表里的 sender 主要是历史成员/退群成员形态members和history,规范化 JSON 哈希完全一致members平均 0.055s,history -n 300平均 0.53s,search --in平均 0.47s,stats平均 0.29smembers正常拒绝;unread、new-messages、全局search均能跑通未跑完整 cross-target check:当前 macOS 本机缺 Linux/Windows C 交叉工具链,
zstd-sys/libsqlite3-sys会在 C 编译阶段卡住。本 PR 没有新增平台分支或 C 依赖。