feat(onebot): expose bidirectional message history
Add reverse_order to group and private history actions, preserve latest-page behavior without an anchor, and keep local fallback results chronologically ordered. Key self-sent private messages and reply targets by the conversation peer, reject cross-conversation anchors, and include request context when a server fetch falls back to local history. Refs #229
This commit is contained in:
17 files changed
+468
-70
No files matched your search
@@ -48,17 +48,23 @@ describe('fetchC2cMessageRange / SsoGetC2cMsg', () => {
|
||||
contentHead: { msgType: 166, sequence: 110, timestamp: 1700000110, msgId: 7110 },
|
||||
body: { richText: { elems: [{ text: { str: 'hi' } }] } },
|
||||
},
|
||||
{
|
||||
responseHead: { fromUin: 10001, toUin: 333, forward: { friendName: 'Self' } },
|
||||
contentHead: { msgType: 166, sequence: 115, timestamp: 1700000115, msgId: 7115 },
|
||||
body: { richText: { elems: [{ text: { str: 'sent' } }] } },
|
||||
},
|
||||
],
|
||||
});
|
||||
const sender = { sendRawPacket: async () => okResult(resp) };
|
||||
|
||||
const out = await fetchC2cMessageRange(sender, identity, 10001, 'u_friend', 100, 120);
|
||||
|
||||
expect(out.map((m) => m.msgSeq)).toEqual([110, 120]); // sorted ascending
|
||||
expect(out.map((m) => m.msgSeq)).toEqual([110, 115, 120]); // sorted ascending
|
||||
expect(out.every((m) => m.kind === 'friend_message')).toBe(true);
|
||||
expect(out.every((m) => m.selfUin === 10001)).toBe(true);
|
||||
expect(out[0]).toMatchObject({ msgSeq: 110, senderUin: 111, senderNick: 'Alice' });
|
||||
expect(out[1]).toMatchObject({ msgSeq: 120, senderUin: 222, senderNick: 'Bob' });
|
||||
expect(out[1]).toMatchObject({ msgSeq: 115, senderUin: 10001, peerUin: 333, senderNick: 'Self' });
|
||||
expect(out[2]).toMatchObject({ msgSeq: 120, senderUin: 222, senderNick: 'Bob' });
|
||||
});
|
||||
|
||||
it('drops content-less blank messages, keeps real ones (#102 parity)', async () => {
|
||||
|
||||
Reference in new issue
Block a user