feat(protocol): send and receive official my-device chats

Pad and phone device conversations were missing from the friend list
and arrived as empty private messages. They now show up as stable
contacts and support text send/receive.

Fixes #452
This commit is contained in:
DrSmoothl committed 2026-09-14 19:34:42 +08:00
1 parent 60c9669abd
commit dac3deb7bd
16 files changed
+692 -17

No files matched your search

@@ -1,3 +1,4 @@
import { tryDecodeDatalineFriendMessage } from '../../dataline/decode-push';
import type { FriendMessage } from '../../events';
import type { MsgPushDecoder } from '../registry';
import { decodeRichBody } from '../rich-body-decoder';
@@ -24,6 +25,9 @@ function parseGroupInviteCard(jsonText: string): { groupUin: number; sequence: n
}
export const decodeFriendMessage: MsgPushDecoder = (ctx) => {
const dataline = tryDecodeDatalineFriendMessage(ctx);
if (dataline) return [dataline];
const elements = decodeRichBody(ctx.body, false);
const sentBySelf = ctx.fromUin > 0 && ctx.fromUin === ctx.selfUin;
const peerUin = sentBySelf ? (ctx.responseHead?.toUin ?? 0) : ctx.fromUin;