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:
5 files changed
+70
-98
No files matched your search
@@ -9,6 +9,7 @@ import type {
|
||||
NotOnlineImage,
|
||||
QFaceExtra,
|
||||
QSmallFaceExtra,
|
||||
SrcMsgPbReserve,
|
||||
} from '@snowluma/proto-defs/element';
|
||||
import type { FileExtra, MessageBody, RichText } from '@snowluma/proto-defs/message';
|
||||
import { decompressData, makeImageUrl } from './helpers';
|
||||
@@ -21,7 +22,7 @@ export function decodeRichBody(body: PushMsgBody | undefined, isGroup: boolean):
|
||||
const elements: MessageElement[] = [];
|
||||
if (body?.richText) {
|
||||
const rt = body.richText;
|
||||
if (rt.elems) elements.push(...convertElements(rt.elems as ElemDecoded[]));
|
||||
if (rt.elems) elements.push(...convertElements(rt.elems as ElemDecoded[], isGroup));
|
||||
extractRichtextExtras(rt, elements, isGroup);
|
||||
}
|
||||
if (body?.msgContent && body.msgContent.length > 0) {
|
||||
@@ -30,16 +31,27 @@ export function decodeRichBody(body: PushMsgBody | undefined, isGroup: boolean):
|
||||
return elements;
|
||||
}
|
||||
|
||||
function convertElements(elems: ElemDecoded[]): MessageElement[] {
|
||||
function convertElements(elems: ElemDecoded[], isGroup: boolean): MessageElement[] {
|
||||
const result: MessageElement[] = [];
|
||||
let skipNext = false;
|
||||
|
||||
for (const elem of elems) {
|
||||
if (skipNext) { skipNext = false; continue; }
|
||||
|
||||
// Reply / quote
|
||||
if (elem.srcMsg?.origSeqs && elem.srcMsg.origSeqs.length > 0) {
|
||||
result.push({ type: 'reply', replySeq: elem.srcMsg.origSeqs[0] });
|
||||
// Reply / quote. For a c2c (friend) reply the canonical replied-to sequence
|
||||
// is the srcMsg reserve's `friendSequence`, NOT `origSeqs[0]` — origSeqs
|
||||
// carries the per-sender clientSequence, which doesn't match how the
|
||||
// original message is keyed (by its server/private sequence), so resolving
|
||||
// the reply (and get_msg on the quoted message) would miss. Mirrors
|
||||
// Lagrange's `Sequence = reserve.FriendSequence ?? OrigSeqs[0]`
|
||||
// (ForwardEntity.cs). Group replies keep origSeqs[0] (the shared group seq).
|
||||
if (elem.srcMsg) {
|
||||
let replySeq = elem.srcMsg.origSeqs?.[0] ?? 0;
|
||||
if (!isGroup && elem.srcMsg.pbReserve && elem.srcMsg.pbReserve.length > 0) {
|
||||
const reserve = protobuf_decode<SrcMsgPbReserve>(elem.srcMsg.pbReserve);
|
||||
if (reserve.friendSequence) replySeq = reserve.friendSequence;
|
||||
}
|
||||
if (replySeq > 0) result.push({ type: 'reply', replySeq });
|
||||
}
|
||||
|
||||
// Text (with possible @ detection)
|
||||
|
||||
Reference in new issue
Block a user