fix(onebot): correct private message history (#256)

Use the C2C roam cursor and canonical NT sequence for bidirectional history. Persist direction-aware recall tombstones so recalled messages cannot reappear.
This commit is contained in:
DrSmoothl committed 2026-07-20 22:25:13 +08:00
1 parent 88216ce644
commit 4aa2cd1693
37 files changed
+1853 -242

No files matched your search

+4 -6
View File
@@ -222,11 +222,9 @@ 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)).
// Decoded content of SrcMsg.pbReserve(8). `friendSequence` is a friendship-side
// counter observed in QQNT, not the conversation-wide C2C NT message sequence;
// private reply resolution therefore uses SrcMsg.origSeqs plus direction/time.
export interface SrcMsgPbReserve {
receiverUid?: pb<7, string>;
friendSequence?: pb<8, uint_32>;
@@ -436,4 +434,4 @@ export interface Preserve {
senderUid?: pb<6, string>;
receiverUid?: pb<7, string>;
clientSequence?: pb<8, uint_32>;
}
}
+21 -2
View File
@@ -1,8 +1,9 @@
import type { pb, pb_repeated, uint_32 } from '@snowluma/proton';
import type { pb, pb_repeated, uint_32, bool } from '@snowluma/proton';
import type { PushMsgBody } from './message';
// trpc.msg.register_proxy.RegisterProxy.SsoGetC2cMsg — fetch private (c2c)
// message history from the server by sequence range. Reference: Lagrange.Core
// message history from the server by conversation-wide NT sequence range.
// Reference: Lagrange.Core
// Internal/Service/Message/GetC2cMessageService.cs + Packets/Message/Action/
// SsoGetC2cMsg(.Response).cs. The peer is the friend's UID (not uin); the
// response carries the same `PushMsgBody` shape as a live message.
@@ -17,3 +18,21 @@ export interface SsoGetC2cMsgResponse {
friendUid?: pb<4, string>;
messages?: pb_repeated<7, PushMsgBody>;
}
// trpc.msg.register_proxy.RegisterProxy.SsoGetRoamMsg — fetch private
// history before a timestamp cursor. This is QQ's latest-page C2C history
// endpoint; unlike SsoGetC2cMsg it does not require a locally known sequence.
export interface SsoGetRoamMsg {
friendUid?: pb<1, string>;
time?: pb<2, uint_32>;
random?: pb<3, uint_32>;
count?: pb<4, uint_32>;
direction?: pb<5, bool>;
}
export interface SsoGetRoamMsgResponse {
friendUid?: pb<3, string>;
timestamp?: pb<5, uint_32>;
random?: pb<6, uint_32>;
messages?: pb_repeated<7, PushMsgBody>;
}
+4
View File
@@ -52,6 +52,10 @@ export interface ContentHead {
sequence?: pb<5, uint_32>;
timestamp?: pb<6, uint_32>;
field7?: pb<7, uint_64>;
/** Conversation-wide C2C sequence. Unlike field 5, this advances across
* messages sent by either participant and is the sequence accepted by
* SsoGetC2cMsg. It is absent on group messages. */
ntMsgSeq?: pb<11, uint_32>;
newId?: pb<12, uint_64>;
}