fix(protocol): guard identity.findGroup in group decoder (#212)

9b470d0 added ctx.identity.findGroup() to the group-message decoder for
the group_name cache fallback, but several suites mock a minimal identity
without findGroup, so decodeGroupMessage threw at runtime once the
typecheck gate (fixed in 5e73d69) let CI reach the test phase — forward /
packet-pipeline-stranger-resolve / msg-push-handler. Optional-chain the
call: the real IdentityService always has findGroup; only test mocks omit
it, and an absent cache simply yields no fallback name.
This commit is contained in:
DrSmoothl committed 2026-07-09 23:13:40 +08:00
1 parent 5e73d69663
commit b37b17f7d8
1 file changed
+1 -1
@@ -47,6 +47,6 @@ export const decodeGroupMessage: MsgPushDecoder = (ctx) => {
// Group name: prefer the message's own wire field (ResponseGrp field 7 —
// fresh even right after a rename), fall back to the cached group list, else
// leave it empty. `ev.groupId` is set above from grp.groupUin.
ev.groupName = grp?.groupName || ctx.identity.findGroup(ev.groupId)?.groupName || '';
ev.groupName = grp?.groupName || ctx.identity.findGroup?.(ev.groupId)?.groupName || '';
return [ev];
};