fix(onebot): resolve c2c reply target by srcMsg friendSequence, not origSeqs

Replying to a bot self-sent private message still failed get_msg on the quoted
id ("无法解析申请信息"). Root cause is the reply DECODE, not the keying: for a
c2c (friend) reply the canonical replied-to sequence is carried in
srcMsg.pbReserve.friendSequence (tag 8), while origSeqs[0] holds the per-sender
clientSequence. The decoder read origSeqs[0], so the reply resolved to a
sequence that never matches how the original message is keyed (by its server /
private sequence) — get_msg missed. Mirrors Lagrange's incoming-reply rule
`Sequence = reserve.FriendSequence ?? OrigSeqs[0]` (ForwardEntity.cs +
SourceMsg.PbPreserve.cs ProtoMember(8)).

- proto-defs: +SrcMsgPbReserve { receiverUid@7, friendSequence@8 }
- protocol: decodeRichBody reads friendSequence for c2c replies (group keeps
  origSeqs[0], the shared group seq); fall back to origSeqs[0] when absent
- tests: c2c→friendSequence, group→origSeqs[0], no-reserve→fallback

This supersedes the keying approach in 4571864 (self-sent c2c keyed by
clientSequence), which is fully reverted here: the message is keyed by its
private sequence as before, and the fix is purely on the decode side so it also
covers replies to *received* old c2c messages, not just self-sent ones.
This commit is contained in:
DrSmoothl committed 2026-06-15 11:58:28 +08:00
1 parent 457186419f
commit cf8e62d2ac
5 files changed
+70 -98

No files matched your search

+10
View File
@@ -222,6 +222,16 @@ export interface SrcMsg {
troopName?: pb<11, bytes>;
}
// Decoded content of SrcMsg.pbReserve(8). For a c2c (friend) reply the
// canonical replied-to sequence lives here as `friendSequence`, NOT in
// `origSeqs` (which carries the per-sender clientSequence). Lagrange resolves an
// incoming reply as `Sequence = reserve.FriendSequence ?? OrigSeqs[0]`
// (dev/Lagrange.Core/.../SourceMsg.PbPreserve.cs ProtoMember(8)).
export interface SrcMsgPbReserve {
receiverUid?: pb<7, string>;
friendSequence?: pb<8, uint_32>;
}
export interface LightAppElem {
data?: pb<1, bytes>;
msgResid?: pb<2, bytes>;