feat(protocol): decode online device snapshots

Decode Event 0x210 subtype 349 into typed online-device snapshots, including QQ-compatible low-byte client type normalization and one-entry-per-device-category projection.

Keep replacement snapshots outside system-message deduplication, reject malformed device identities observably, and add wire-level regressions for complete, packed, repeated, and invalid payloads. Live verification covered mobile account switching without requiring native changes.
This commit is contained in:
DrSmoothl committed 2026-07-19 19:19:58 +08:00
1 parent e6a69b05a7
commit b92c8ad881
8 files changed
+279 -3

No files matched your search

+13 -1
View File
@@ -57,6 +57,13 @@ const MESSAGE_KINDS = new Set<QQEventVariant['kind']>([
'friend_message', 'group_message', 'temp_message',
]);
// Replacement snapshots describe the complete current state. They are
// idempotent, but not duplicate events: a later snapshot may legitimately
// reuse the enclosing system-message identity while carrying new state.
const STATE_SNAPSHOT_KINDS = new Set<QQEventVariant['kind']>([
'online_devices_changed',
]);
/**
* Summarise a body that decoded to zero elements despite carrying content —
* each element's field names, every `commonElem`'s serviceType/businessType +
@@ -127,7 +134,12 @@ export function parseMsgPush(
// messages have their own NT dedup path and the forward re-parse re-runs
// this without a tracker. A push that decodes to a message kind, or to
// nothing, is never deduped here.
if (dedup && out.length > 0 && out.every((ev) => !MESSAGE_KINDS.has(ev.kind))) {
if (
dedup
&& out.length > 0
&& out.every((ev) => !MESSAGE_KINDS.has(ev.kind))
&& out.every((ev) => !STATE_SNAPSHOT_KINDS.has(ev.kind))
) {
if (dedup.seenDuplicate(ctx.head, ctx.fromUin)) {
log.debug('dropped duplicate system push (kinds=%s seq=%d from=%d msgType=%d msgId=%d)',
out.map((ev) => ev.kind).join(','), ctx.head.sequence, ctx.fromUin, ctx.head.msgType, ctx.head.msgId);