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

@@ -17,6 +17,7 @@ import type {
QQEventVariant,
TempMessage,
} from '@snowluma/protocol/events';
import { PRIVATE_SENT_MESSAGE_EVENT } from '../src/message-id';
const SELF_ID = 10001;
const PEER_UIN = 22222;
@@ -355,6 +356,7 @@ describe('convertEvent — message elements (13 segment types)', () => {
const segments = await elementsToOneBotSegments(
[element], false, PEER_UIN,
ctx.imageUrlResolver, ctx.mediaUrlResolver, ctx.messageIdResolver, ctx.mediaSegmentSink,
ctx.selfId,
);
return segments[0] as unknown as Segment;
}
@@ -436,6 +438,28 @@ describe('convertEvent — message elements (13 segment types)', () => {
expect(seg).toEqual({ type: 'reply', data: { id: '9999' } });
});
it('reply: self-sent private targets use the outgoing lookup namespace', async () => {
const calls: unknown[][] = [];
const seg = await segment(
{ type: 'reply', replySeq: 5, replySenderUin: SELF_ID, replyTime: 1234 },
{
messageIdResolver: (...args) => {
calls.push(args);
return 9999;
},
},
);
expect(seg).toEqual({ type: 'reply', data: { id: '9999' } });
expect(calls[0]).toEqual([
false,
PEER_UIN,
5,
PRIVATE_SENT_MESSAGE_EVENT,
1234,
]);
});
it('reply: replySeq=0 -> id "0", no resolver call', async () => {
let resolverCalls = 0;
const seg = await segment(