fix(onebot): keep synthetic sequences out of history

Distinguish QQ-authoritative message sequences from local message IDs so group files and reply placeholders cannot become history anchors or be reused by protocol actions.

Filter QQ null roam records and migrate previously stored synthetic rows.

Fixes #254
This commit is contained in:
DrSmoothl committed 2026-07-20 15:33:28 +08:00
1 parent 2c8a8af514
commit 4ba2b27398
17 files changed
+758 -45

No files matched your search

@@ -16,6 +16,7 @@ function fakeMeta(overrides: Partial<MessageMeta> = {}): MessageMeta {
isGroup: true,
targetId: 100,
sequence: 555,
sequenceAuthoritative: true,
eventName: 'group_message',
clientSequence: 0,
random: 0,
@@ -648,6 +649,19 @@ describe('extended-actions / set_/complete_/cancel_group_todo', () => {
expect(res).toMatchObject({ status: 'failed', retcode: 100 });
});
it('rejects a local-only message id without calling the group todo protocol', async () => {
const setGroupTodo = vi.fn(async () => {});
const bridge = fakeBridge({ setGroupTodo });
const ctx = fakeCtx(bridge, {
getMessageMeta: () => fakeMeta({ sequence: 0, sequenceAuthoritative: false }),
});
const res = await makeHandler(ctx).handle('set_group_todo', { group_id: 100, message_id: 1 });
expect(res).toMatchObject({ status: 'failed', retcode: 100 });
expect(setGroupTodo).not.toHaveBeenCalled();
});
it('rejects missing params', async () => {
const r1 = await makeHandler(fakeCtx(fakeBridge())).handle('set_group_todo', { message_id: 1 });
const r2 = await makeHandler(fakeCtx(fakeBridge())).handle('set_group_todo', { group_id: 1 });
@@ -656,6 +670,26 @@ describe('extended-actions / set_/complete_/cancel_group_todo', () => {
});
});
describe('extended-actions / set_group_reaction', () => {
it('rejects a local-only message id without calling the reaction protocol', async () => {
const setGroupReaction = vi.fn(async () => {});
const bridge = fakeBridge({ setGroupReaction });
const ctx = fakeCtx(bridge, {
getMessageMeta: () => fakeMeta({ sequence: 0, sequenceAuthoritative: false }),
});
const res = await makeHandler(ctx).handle('set_group_reaction', {
group_id: 100,
message_id: 1,
code: '66',
is_set: true,
});
expect(res).toMatchObject({ status: 'failed', retcode: 100 });
expect(setGroupReaction).not.toHaveBeenCalled();
});
});
// ─── Tier 2: nc_get_user_status ───
describe('extended-actions / nc_get_user_status', () => {