feat(onebot): tiered reply backfill + quoted-file recovery for get_msg (#128)
Harvests the sound ideas from PR #128 while KEEPING origSeqs[0] as the c2c reply sequence (on-target capture in #114/#124 proved origSeqs[0] == the quoted message's head.sequence; pbReserve.friendSequence is a small unrelated counter that makes reply.id miss). The PR's friendSequence override is intentionally NOT taken. - rich-body-decoder: enrich the reply element with replySenderUin/replyTime and the quoted message's own decoded elements (SrcMsg.elems, field 5); recover a c2c quoted FILE from sourceMsg (field 9 -> RichText.notOnlineFile) when elems carried none, so a quoted file survives into get_msg (#124). - backfillReplyTarget: tiered fallback — Tier 0 local store, Tier 1 server fetch (correct seq = origSeqs[0]), Tier 2 reconstruct from the embedded quoted elements (no round-trip), Tier 3 minimal '[引用消息]' placeholder so get_msg never returns 'message not found'. - to-segment: per-element try/catch (logged, not silent) so one bad element doesn't drop the whole message. - actions/message: log get_msg misses. - tests: fix request-actions getGroupInviteCardSequence mock (gap from #125); cover backfill Tier 2 (reconstruct) + Tier 3 (placeholder); flip the stale c2c reply test to assert origSeqs[0] (was asserting the disproven friendSequence). Validated on-target (Docker): get_msg on group reply, private text reply, and a private quoted FILE all return correct content (file with name/size/id); full onebot + protocol suites green.
This commit is contained in:
8 files changed
+189
-34
No files matched your search
@@ -165,13 +165,15 @@ describe('decodeRichBody / market face', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// Reply identity for c2c: a friend's reply carries the per-sender
|
||||
// clientSequence in srcMsg.origSeqs[0], but the *canonical* replied-to sequence
|
||||
// (the one the original message is keyed by) is srcMsg.pbReserve.friendSequence.
|
||||
// Reading origSeqs[0] made get_msg on the quoted message miss ("无法解析申请信息").
|
||||
describe('decodeRichBody / reply uses friendSequence for c2c', () => {
|
||||
const CLIENT_SEQ = 23188; // origSeqs[0] — per-sender clientSequence
|
||||
const FRIEND_SEQ = 888; // pbReserve.friendSequence — canonical replied-to seq
|
||||
// Reply identity for c2c: the replied-to sequence is srcMsg.origSeqs[0] for BOTH
|
||||
// group 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 —
|
||||
// while pbReserve.friendSequence is a small friend-relationship counter that does
|
||||
// NOT match (e.g. 25 vs a head.sequence of 12707). Reading friendSequence made
|
||||
// reply.id != the quoted message_id, so get_msg(reply_id) missed.
|
||||
describe('decodeRichBody / reply uses origSeqs[0] for c2c', () => {
|
||||
const CLIENT_SEQ = 23188; // origSeqs[0] — the quoted message's head.sequence
|
||||
const FRIEND_SEQ = 888; // pbReserve.friendSequence — a small unrelated counter, ignored
|
||||
|
||||
function replyBody(): MessageBody {
|
||||
return {
|
||||
@@ -188,8 +190,9 @@ describe('decodeRichBody / reply uses friendSequence for c2c', () => {
|
||||
};
|
||||
}
|
||||
|
||||
it('c2c: replySeq = friendSequence, not origSeqs[0]', () => {
|
||||
expect(decodeRichBody(replyBody(), false)).toContainEqual({ type: 'reply', replySeq: FRIEND_SEQ });
|
||||
it('c2c: replySeq = origSeqs[0], not friendSequence (#114/#124)', () => {
|
||||
expect(decodeRichBody(replyBody(), false)).toContainEqual({ type: 'reply', replySeq: CLIENT_SEQ });
|
||||
expect(FRIEND_SEQ).not.toBe(CLIENT_SEQ); // guard: the two must differ for this to mean anything
|
||||
});
|
||||
|
||||
it('group: replySeq = origSeqs[0] (friendSequence ignored)', () => {
|
||||
|
||||
Reference in new issue
Block a user