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:
17 files changed
+758
-45
No files matched your search
@@ -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();
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user