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
@@ -188,6 +188,38 @@ describe('MessageStore', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('listSessionEvents', () => {
|
||||
function storeGroupSequence(groupId: number): void {
|
||||
for (let sequence = 1; sequence <= 5; sequence++) {
|
||||
store.storeEvent(sequence, true, groupId, sequence, GROUP_MESSAGE_EVENT, {
|
||||
post_type: 'message',
|
||||
message_type: 'group',
|
||||
group_id: groupId,
|
||||
message_id: sequence,
|
||||
message_seq: sequence,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
it('returns the anchor and newer messages in chronological order', () => {
|
||||
const groupId = 123456;
|
||||
storeGroupSequence(groupId);
|
||||
|
||||
const messages = store.listSessionEvents(true, groupId, 3, 3, false);
|
||||
|
||||
expect(messages.map((message) => message.message_seq)).toEqual([3, 4, 5]);
|
||||
});
|
||||
|
||||
it('keeps the anchor and older messages as the default', () => {
|
||||
const groupId = 123456;
|
||||
storeGroupSequence(groupId);
|
||||
|
||||
const messages = store.listSessionEvents(true, groupId, 3, 3);
|
||||
|
||||
expect(messages.map((message) => message.message_seq)).toEqual([1, 2, 3]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('listReadSessions', () => {
|
||||
it('uses current groups and only genuine incoming friend sessions', () => {
|
||||
const event = (postType: string, subType: string) => ({
|
||||
|
||||
Reference in new issue
Block a user