refactor(protocol): keep Decoder a pure parse of MsgPush events

Decoder used to write Identity: decodeGroupAdmin patched member roles
and decodeFriendMessage stashed invite-card msgseq. That split
observation with IncomingPacketPipeline.rememberEventIdentity and put
pending-application state on Identity.

Decoder now only returns events. Invite-card groupUin/msgseq ride on
FriendMessage; the live pipeline writes them to ContactsApi through
an optional port. Role self-heal for #93 stays in
rememberEventIdentity. History and forward decode do not write.
Identity no longer stores invite-card sequences.

Live #93 and #125 behavior is unchanged.
This commit is contained in:
DrSmoothl committed 2026-08-16 18:22:41 +08:00
1 parent fea1996e46
commit 226b48fd7a
12 files changed
+148 -79

No files matched your search

@@ -21,21 +21,6 @@ export const decodeGroupAdmin: MsgPushDecoder = (ctx) => {
const set = !!enableUid;
const userUin = resolveUidToUin(ctx.identity, groupId, adminUid);
// Keep the in-memory member cache in step with the promotion/demotion.
// `get_group_member_info` serves straight from this cache on its
// default (no_cache=false) path — and we deliberately *don't*
// force-refresh there, because clients like OlivaDice/MaiBot query it
// once per inbound message and a per-message OIDB refetch trips
// Tencent risk-control (see the ContactsApi member-list cache). So if
// we don't patch the role here, a freshly-promoted admin keeps reading
// back as `member` until the member-list TTL lapses, and permission
// gates reject their commands (#93). Only touch a member we already
// know, and never downgrade the owner.
const cached = ctx.identity.findGroupMember(groupId, userUin);
if (cached && cached.role !== 'owner') {
ctx.identity.updateGroupMember(groupId, { ...cached, role: set ? 'admin' : 'member' });
}
const ev: GroupAdminEvent = {
kind: 'group_admin',
time: ctx.head.timestamp,