mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-12-01 09:15:41 +08:00
fix(wecom): 修正消息去重、成员读取失败判定与群名解析顺序
合并键改为 create_time + local_id + server_id 完全一致,避免 server_id 复用把不同消息折叠 企业群成员读取失败返回 null,与合法空列表区分,同步与异步通道口径一致 新增同步群名解析入口,使冷启动会话列表、群列表与群日报显示同一群名 批量成员读取按普通群与企业群分流,避免混批导致整批 native 查询失败 补充真实数据脱敏只读验收报告与企业成员批量用例
This commit is contained in:
1 parent
8f37ded71e
commit
9b9a1722cd
9 files changed
+500
-47
No files matched your search
@@ -36,6 +36,80 @@ describe(`enterprise group name and member mapping`, () => {
|
||||
expect(memberIds(null)).toEqual([])
|
||||
})
|
||||
|
||||
it(`distinguishes a failed enterprise member read from a genuinely empty group`, async () => {
|
||||
const stub = (impl: Record<string, unknown>) => {
|
||||
impl.wcdbExecQuery = () => 0
|
||||
return impl
|
||||
}
|
||||
|
||||
const failed = new Wcdb4Client(`00`, join(root, `fixture-account`))
|
||||
const failedImpl = stub(failed as unknown as Record<string, unknown>)
|
||||
failedImpl.callJson = () => {
|
||||
throw new Error(`fixture native failure`)
|
||||
}
|
||||
failedImpl.callJsonAsync = () => Promise.reject(new Error(`fixture native failure`))
|
||||
expect(failed.getEnterpriseGroupMembers(`fixture@qy_g`)).toBeNull()
|
||||
await expect(failed.getEnterpriseGroupMembersAsync(`fixture@qy_g`)).resolves.toBeNull()
|
||||
|
||||
const empty = new Wcdb4Client(`00`, join(root, `fixture-account`))
|
||||
const emptyImpl = stub(empty as unknown as Record<string, unknown>)
|
||||
emptyImpl.callJson = () => []
|
||||
emptyImpl.callJsonAsync = () => Promise.resolve([])
|
||||
expect(empty.getEnterpriseGroupMembers(`fixture@qy_g`)).toEqual([])
|
||||
await expect(empty.getEnterpriseGroupMembersAsync(`fixture@qy_g`)).resolves.toEqual([])
|
||||
|
||||
const unavailable = new Wcdb4Client(`00`, join(root, `fixture-account`))
|
||||
expect(unavailable.getEnterpriseGroupMembers(`fixture@qy_g`)).toBeNull()
|
||||
})
|
||||
|
||||
it(`resolves an enterprise group name on a cold cache without waiting for hydration`, () => {
|
||||
const client = new Wcdb4Client(`00`, join(root, `fixture-account`))
|
||||
const impl = client as unknown as Record<string, unknown>
|
||||
impl.wcdbExecQuery = () => 0
|
||||
let calls = 0
|
||||
impl.callJson = () => {
|
||||
calls += 1
|
||||
return [{ chat_name: `fixture group name` }]
|
||||
}
|
||||
|
||||
// 冷缓存:同步快照路径第一次取群名就必须拿到真实群名,而不是 raw username。
|
||||
expect(client.getEnterpriseGroupName(`fixture@qy_g`)).toBe(`fixture group name`)
|
||||
// 第二次命中缓存,不再打库。
|
||||
expect(client.getEnterpriseGroupName(`fixture@qy_g`)).toBe(`fixture group name`)
|
||||
expect(calls).toBe(1)
|
||||
|
||||
// 非企业会话不参与该通道。
|
||||
expect(client.getEnterpriseGroupName(`fixture@chatroom`)).toBe(``)
|
||||
})
|
||||
|
||||
it(`gives the sync session list the same enterprise group name as hydration`, () => {
|
||||
const client = new Wcdb4Client(`00`, join(root, `fixture-account`))
|
||||
const impl = client as unknown as Record<string, unknown>
|
||||
impl.wcdbExecQuery = () => 0
|
||||
impl.wcdbGetSessions = () => 0
|
||||
let calls = 0
|
||||
impl.callJson = () => {
|
||||
calls += 1
|
||||
return [{ chat_name: `fixture group name` }]
|
||||
}
|
||||
impl.callJsonAsync = () => Promise.resolve([{ chat_name: `fixture group name` }])
|
||||
impl.readSessionRows = () => [
|
||||
{ username: `fixture@qy_g`, nickname: `fixture@qy_g`, sort_timestamp: 1 },
|
||||
{ username: `fixture@qy_u`, nickname: `fixture single chat`, sort_timestamp: 2 }
|
||||
]
|
||||
|
||||
// 冷启动:同步列表第一次就显示真实群名,不出现 raw username。
|
||||
const sessions = client.getSessions()
|
||||
expect(sessions.find((item) => item.username === `fixture@qy_g`)?.nickname).toBe(
|
||||
`fixture group name`
|
||||
)
|
||||
// 企业单聊不走群名通道,保持自己的昵称。
|
||||
expect(sessions.find((item) => item.username === `fixture@qy_u`)?.nickname).toBe(
|
||||
`fixture single chat`
|
||||
)
|
||||
expect(calls).toBe(1)
|
||||
})
|
||||
|
||||
it(`maps user_info rows to member display names`, () => {
|
||||
const members = membersFromRows(
|
||||
[`wwfixture_user_a@qy_u`, `wwfixture_user_b@qy_u`],
|
||||
|
||||
Reference in new issue
Block a user