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
@@ -117,6 +117,29 @@ describe('backfillReplyTarget', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('c2c: a self-sent reply echo backfills under the conversation peer', async () => {
|
||||
const peerUin = 448671521;
|
||||
const store = fakeStore(false);
|
||||
const getC2cMessageBySeq = vi.fn(async () => fetchedFriendMessage(456, peerUin));
|
||||
const ref = {
|
||||
selfId: SELF, converterCtx, messageStore: store,
|
||||
bridge: { apis: { message: { getC2cMessageBySeq } }, resolveUserUid: vi.fn(async () => 'u_friend') },
|
||||
} as any;
|
||||
const event = {
|
||||
kind: 'friend_message', time: 1, selfUin: SELF, senderUin: SELF, peerUin,
|
||||
senderNick: '', msgSeq: 999, msgId: 2,
|
||||
elements: [{ type: 'reply', replySeq: 456 }],
|
||||
} as any;
|
||||
|
||||
await backfillReplyTarget(ref, event);
|
||||
|
||||
const targetId = hashMessageIdInt32(456, peerUin, PRIVATE_MESSAGE_EVENT);
|
||||
expect(store.storeEvent).toHaveBeenCalledWith(
|
||||
targetId, false, peerUin, 456, PRIVATE_MESSAGE_EVENT,
|
||||
expect.objectContaining({ message_id: targetId, message_type: 'private' }),
|
||||
);
|
||||
});
|
||||
|
||||
it('no-op when the quoted message is already stored (no fetch)', async () => {
|
||||
const store = fakeStore(true); // findEvent hits
|
||||
const getGroupMessageBySeq = vi.fn();
|
||||
|
||||
Reference in new issue
Block a user