A private (c2c) reply resolved to srcMsg.reserve.friendSequence, but a received message's message_id is hashed from its head.sequence. On-target capture showed origSeqs[0] == head.sequence (e.g. 12709) while friendSequence is a small friend-relationship counter (e.g. 25) — so reply.id != the quoted message_id. Downstream get_msg(reply_id) then missed: - #114: reported reply id didn't match the quoted message's real id. - #124: replying to a File message returned empty quoted content (AstrBot relies on get_msg(reply_id) to learn the quote was a file; text replies appeared fine because they read the inline follow-up text instead). Drop the c2c friendSequence override (reverting cf8e62d's premise, which was backwards) so both group and c2c replies use origSeqs[0]. Validated on-target (Docker): file message id == reply.id, and get_msg(reply_id) -> retcode 0, message [{type:file}].
This commit is contained in:
1 file changed
+11
-8
@@ -9,7 +9,6 @@ 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';
|
||||
@@ -22,7 +21,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[], isGroup));
|
||||
if (rt.elems) elements.push(...convertElements(rt.elems as ElemDecoded[]));
|
||||
extractRichtextExtras(rt, elements, isGroup);
|
||||
}
|
||||
if (body?.msgContent && body.msgContent.length > 0) {
|
||||
@@ -31,7 +30,7 @@ export function decodeRichBody(body: PushMsgBody | undefined, isGroup: boolean):
|
||||
return elements;
|
||||
}
|
||||
|
||||
function convertElements(elems: ElemDecoded[], isGroup: boolean): MessageElement[] {
|
||||
function convertElements(elems: ElemDecoded[]): MessageElement[] {
|
||||
const result: MessageElement[] = [];
|
||||
let skipNext = false;
|
||||
|
||||
@@ -46,11 +45,15 @@ function convertElements(elems: ElemDecoded[], isGroup: boolean): MessageElement
|
||||
// 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;
|
||||
}
|
||||
// The reply resolves to srcMsg.origSeqs[0] — for BOTH group (shared group
|
||||
// seq) and c2c. On-target capture (#114 / #124) proved origSeqs[0] equals
|
||||
// the quoted message's head.sequence, i.e. the seq its message_id is
|
||||
// hashed from. reserve.friendSequence is a small friend-relationship
|
||||
// counter that does NOT match (e.g. 25 vs a head.sequence of 12707), so
|
||||
// the earlier `friendSequence` override made reply.id != the quoted
|
||||
// message_id: get_msg(reply_id) missed and a quoted File's content came
|
||||
// back empty.
|
||||
const replySeq = elem.srcMsg.origSeqs?.[0] ?? 0;
|
||||
if (replySeq > 0) result.push({ type: 'reply', replySeq });
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user