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

+8 -1
View File
@@ -2,7 +2,7 @@ import { readFile } from 'node:fs/promises';
import type { ApiActionContext } from '../api-handler';
import { asNumber, asString } from '../api-handler';
import type { ForwardPreviewMeta } from '../modules/message-actions';
import { JsonObject, RETCODE, failedResponse, okResponse } from '../types';
import { hasAuthoritativeSequence, RETCODE, failedResponse, okResponse, type JsonObject } from '../types';
import { defineAction, groupAction, groupUserAction, f } from '../action-kit';
import { GROUP_MESSAGE_EVENT, hashMessageIdInt32 } from '../message-id';
@@ -111,6 +111,9 @@ async function groupTodoRun(
if (!meta.isGroup || meta.targetId !== p.group_id) {
return failedResponse(RETCODE.ACTION_FAILED, 'message does not belong to this group');
}
if (!hasAuthoritativeSequence(meta)) {
return failedResponse(RETCODE.ACTION_FAILED, 'message has no authoritative QQ sequence');
}
await op(p.group_id, BigInt(meta.sequence));
return okResponse();
}
@@ -245,6 +248,10 @@ export const actions = [
return failedResponse(RETCODE.BAD_REQUEST, 'group_id does not match message session');
}
if (!hasAuthoritativeSequence(meta)) {
return failedResponse(RETCODE.ACTION_FAILED, 'message has no authoritative QQ sequence');
}
await ctx.bridge.apis.interaction.setReaction(meta.targetId, meta.sequence, p.code, p.is_set);
return okResponse();
},