diff --git a/packages/core/src/bridge/msg-push/decoders/event-0x210.ts b/packages/core/src/bridge/msg-push/decoders/event-0x210.ts index 4cbc479f..fadc5dd5 100644 --- a/packages/core/src/bridge/msg-push/decoders/event-0x210.ts +++ b/packages/core/src/bridge/msg-push/decoders/event-0x210.ts @@ -25,6 +25,11 @@ export const decodeEvent0x210: MsgPushDecoder = (ctx) => { case Event0x210SubType.FriendRequestNotice: return decodeFriendRequest(ctx); case Event0x210SubType.FriendRecallNotice: return decodeFriendRecall(ctx); case Event0x210SubType.FriendPokeNotice: return decodeFriendPoke(ctx); + case Event0x210SubType.GroupAppStatePush: + // QQ-client-internal troop shortcut bar / discussion app state + // push — no OneBot-level event. See enum comment for the + // decompiled-source breakdown of the sub_cmd dispatch. + return []; } unknownLog.debug('Event0x210 unknown subType=%d', ctx.head.subType); return []; diff --git a/packages/core/src/bridge/msg-push/enums.ts b/packages/core/src/bridge/msg-push/enums.ts index 38561e87..12ba3f08 100644 --- a/packages/core/src/bridge/msg-push/enums.ts +++ b/packages/core/src/bridge/msg-push/enums.ts @@ -31,4 +31,29 @@ export enum Event0x210SubType { FriendRequestNotice = 35, FriendRecallNotice = 138, FriendPokeNotice = 290, + /** + * Group-app state push (troop shortcut bar / discussion app). + * + * Sourced from the decompiled stock QQ Android client decoder at + * `com.tencent.imcore.message.ext.codec.decoder.msgType0x210.SubType0x26` + * (tsuzcx/qq_apk @ afe46ef). The payload is `submsgtype0x26.MsgBody` + * dispatching on `uint32_sub_cmd`: + * + * - 0x1 → `UpdateAppUnreadNum`: a list of + * `{group_code, app_id, unread_num}` entries the QQ client uses + * to keep group-internal "mini-app" badges (e.g. `appId=101846662` + * / `101896870` for the shortcut bar) in sync. + * - 0x3 → `UpdateDiscussAppInfo`: `{conf_uin, app_tip_notify.text}` + * for discussion-group app tips, routed to `getGAudioHandler()`. + * - 0x4 → delegated to the troop online-push handler. + * + * None of these have a OneBot event mapping — they're QQ-client-UI + * state pushes (unread badges, in-app tips), not user-visible + * conversation events. Acknowledge the subType so it doesn't keep + * showing up as "unknown" in debug logs and drop it silently. + * Lagrange V2 / lagrange-python / LagrangeGo / acidify all also + * fall through on this one because they don't surface the shortcut + * bar either. + */ + GroupAppStatePush = 38, } diff --git a/packages/core/tests/msg-push-handler.test.ts b/packages/core/tests/msg-push-handler.test.ts index 554b5f10..2df80459 100644 --- a/packages/core/tests/msg-push-handler.test.ts +++ b/packages/core/tests/msg-push-handler.test.ts @@ -7,6 +7,7 @@ import { GroupChangeSchema, OperatorInfoSchema } from '../src/bridge/proto/notif import type { GroupMemberJoin } from '../src/bridge/events'; import type { PacketInfo } from '../src/protocol/types'; import { protoEncode } from '../src/protobuf/decode'; +import { subscribeLogs } from '../src/utils/logger'; const SELF_UIN = '10001'; const GROUP_ID = 123456789; @@ -98,3 +99,65 @@ describe('parseMsgPush group member increase', () => { expect(event.operatorUid).toBe(operator.uid); }); }); + +describe('parseMsgPush Event0x210 subType=38 (acknowledged-but-silent)', () => { + // Tracked back to the stock-QQ-android decompiled decoder + // `com.tencent.imcore.message.ext.codec.decoder.msgType0x210.SubType0x26` + // — it's the QQ-client-internal "troop shortcut bar" / discussion + // app state push (badge counts + in-app tips), not a chat event. + // We acknowledge it via `Event0x210SubType.GroupAppStatePush` and + // drop silently — no OneBot-level event, and — critically — + // **no** "unknown subType=38" fallback log spam anymore. + function makeEvent0x210Packet(subType: number, content = new Uint8Array(0)): PacketInfo { + const body = protoEncode({ + message: { + responseHead: { fromUin: 22222, type: 0, sigMap: 0 }, + // 528 = Event0x210 + contentHead: { msgType: 528, subType, timestamp: 1710000000 }, + body: { msgContent: content }, + }, + status: 0, + } as any, PushMsgSchema); + return { + pid: 1, uin: SELF_UIN, serviceCmd: MSG_PUSH_CMD, seqId: 1, + retCode: 0, fromClient: false, body, + }; + } + + it('returns [] for subType 38 without falling through to the MsgPush.Unknown log', () => { + const captured: string[] = []; + const unsubscribe = subscribeLogs((entry) => { + // Only care about the spam that the prior implementation produced + // ("MsgPush.Unknown" with subType=38). Other modules log freely + // during identity setup etc., we ignore them. + if (entry.scope === 'MsgPush.Unknown' && /subType=38/.test(entry.message)) { + captured.push(entry.message); + } + }); + try { + const events = parseMsgPush(makeEvent0x210Packet(38), makeIdentity()); + expect(events).toEqual([]); + expect(captured).toEqual([]); // no "unknown subType=38" debug log + } finally { + unsubscribe(); + } + }); + + it('still flags genuinely-unknown subTypes via MsgPush.Unknown (regression guard)', () => { + // Counterpart to the silent-on-38 case: anything we *haven't* + // claimed in the enum should still hit the fallback so it's + // visible to whoever's tailing debug logs. + const captured: string[] = []; + const unsubscribe = subscribeLogs((entry) => { + if (entry.scope === 'MsgPush.Unknown' && /subType=999/.test(entry.message)) { + captured.push(entry.message); + } + }); + try { + parseMsgPush(makeEvent0x210Packet(999), makeIdentity()); + expect(captured.length).toBeGreaterThan(0); + } finally { + unsubscribe(); + } + }); +});