mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-12-01 01:05:30 +08:00
feat(wecom): 支持企业微信插件会话的消息读取与检索
企业微信插件(Mac 微信 4.2)的群 @qy_g 与会话 @qy_u 消息落在 biz_message_*.db,群/成员元数据落在 bizchat/bizchat.db,而原实现 只把 gh_ 前缀路由到 biz_message_*.db,其余一律读 message_*.db, 导致这些会话在档案/会话列表/搜索中完全缺失。 核心改动: - wcdb4-client: isBizSession/isEnterpriseSession 判定;getMessageDatabasePaths 把 @qy_g/@qy_u 路由到 biz_message_*.db;企业会话跳过本库 Name2Id 联表 - wcdb4-client: parseEnterpriseSource 从 zstd 压缩的 source XML enterprise_info 解析 sender/nickname/bizchat_id - wcdb4-client: hydrateEnterpriseGroupNamesAsync 从 bizchat.chat_group 注入群名 - wcdb4-client: getEnterpriseGroupMembers(Async) 从 chat_group.user_list + user_info.user_name 构建成员列表 - message-parser: 企业图片 <img> 无 md5 但有 aeskey,按 aeskey 补判图片类型 - shared/wechat-identities: isGroupSession/isEnterpriseSession 统一判定 - chat-service/wechat-db/index/local-agent-api/agent-group-report/knowledge-search: 读取与展示链路改用 isGroupSession,覆盖会话列表、群快照、群成员统计、 群日报、知识检索、撤回归档映射 - .gitignore: 排除诊断产物、数据库快照、密钥派生脚本与消息正文 blob 只读改造,未触及发送/插入/退群监控/语音转写/群管理等写入链路。 普通微信好友、@chatroom 群、gh_ 公众号行为保持不变。 验证:4 个 @qy_g 群 + 2 个 @qy_u 单聊可读;chatlog/query-search/ group_snapshot/member-stats 全通过;typecheck:node EXIT=0。
This commit is contained in:
1 parent
518a9662a7
commit
eac16ad8a7
10 files changed
+347
-29
No files matched your search
+16
-7
@@ -1,5 +1,6 @@
|
||||
import { Wcdb4Client, Wcdb4MessageQueryOptions } from './wcdb4-client'
|
||||
import { Wcdb4Client, Wcdb4GroupMember, Wcdb4MessageQueryOptions } from './wcdb4-client'
|
||||
import { wcdbDebugLog } from './wcdb-debug'
|
||||
import { isGroupSession } from '../shared/wechat-identities'
|
||||
|
||||
export interface UserContact {
|
||||
m_nsUsrName: string
|
||||
@@ -140,10 +141,18 @@ export class WechatDb {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一读取群成员:@chatroom 走 native getGroupMembers,@qy_g 走 bizchat 企业群成员。
|
||||
*/
|
||||
private readGroupMembers(roomId: string): Wcdb4GroupMember[] {
|
||||
if (roomId.endsWith('@qy_g')) return this.wcdb4Client.getEnterpriseGroupMembers(roomId)
|
||||
return this.wcdb4Client.getGroupMembers(roomId)
|
||||
}
|
||||
|
||||
public getAllGroupContacts(): Record<string, string> {
|
||||
const groupContacts: Record<string, string> = {}
|
||||
for (const session of this.wcdb4Client.getSessions()) {
|
||||
if (session.username.endsWith('@chatroom')) {
|
||||
if (isGroupSession(session.username)) {
|
||||
groupContacts[this.md5(session.username)] = session.nickname || session.username
|
||||
}
|
||||
}
|
||||
@@ -153,8 +162,8 @@ export class WechatDb {
|
||||
public getAllGroupMembers(): Record<string, string> {
|
||||
const members: Record<string, string> = {}
|
||||
for (const session of this.wcdb4Client.getSessions()) {
|
||||
if (!session.username.endsWith('@chatroom')) continue
|
||||
for (const member of this.wcdb4Client.getGroupMembers(session.username)) {
|
||||
if (!isGroupSession(session.username)) continue
|
||||
for (const member of this.readGroupMembers(session.username)) {
|
||||
if (member.m_nsUsrName) {
|
||||
members[member.m_nsUsrName] = member.nickname || member.m_nsUsrName
|
||||
}
|
||||
@@ -166,10 +175,10 @@ export class WechatDb {
|
||||
public getGroupMembersForChat(userMd5: string): Record<string, string> {
|
||||
this.ensureChatTableMapping()
|
||||
const username = this.chatMd5ToUsername.get(userMd5)
|
||||
if (!username || !username.endsWith('@chatroom')) return {}
|
||||
if (!username || !isGroupSession(username)) return {}
|
||||
|
||||
const members: Record<string, string> = {}
|
||||
for (const member of this.wcdb4Client.getGroupMembers(username)) {
|
||||
for (const member of this.readGroupMembers(username)) {
|
||||
if (member.m_nsUsrName) {
|
||||
members[member.m_nsUsrName] = member.nickname || member.m_nsUsrName
|
||||
}
|
||||
@@ -180,7 +189,7 @@ export class WechatDb {
|
||||
public getGroupMember(wxid: string, chatroomId?: string): GroupMemberInfo | null {
|
||||
if (!chatroomId) return null
|
||||
return (
|
||||
this.wcdb4Client.getGroupMembers(chatroomId).find((member) => member.m_nsUsrName === wxid) ||
|
||||
this.readGroupMembers(chatroomId).find((member) => member.m_nsUsrName === wxid) ||
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user