fix(onebot): allow negative message_id in get_{group,friend}_msg_history
message_id is a signed int32 hash (hashMessageIdInt32) and is frequently
NEGATIVE, but both history actions declared it as `f.int({min:0}).default(0)`
— so a real anchor like message_id=-497311472 was rejected at param
validation (retcode 1400, 0ms) before run() fired, and the server-side
history fetch never happened (the client then reports "未找到足够的群聊记录").
Drop the min:0 bound → `f.int().default(0)`: negatives pass, absent/present-0
still mean "fetch latest", count stays ≥0. Matches every other action, which
uses f.messageId() for signed message IDs.
Regression tests: negative group/friend anchors now reach the handler;
absent message_id still defaults to 0.
This commit is contained in:
2 files changed
+44
-3
No files matched your search
@@ -219,8 +219,12 @@ export const actions = [
|
||||
summary: '获取群消息历史',
|
||||
readOnly: true,
|
||||
params: {
|
||||
// 原实现用 `asNumber(message_id) || 0`,present 0 也映射为 0。
|
||||
message_id: f.int({ min: 0 }).default(0),
|
||||
// message_id is a signed int32 hash (hashMessageIdInt32) and is
|
||||
// frequently NEGATIVE — a `{min:0}` validator rejects a real anchor at
|
||||
// param-validation time (retcode 1400) before run() ever fires. Use a
|
||||
// plain signed int; `.default(0)` keeps absent/present-0 → "fetch latest"
|
||||
// (matches the original `asNumber(message_id) || 0`). `count` stays ≥0.
|
||||
message_id: f.int().default(0),
|
||||
count: f.int({ min: 0 }).default(20),
|
||||
},
|
||||
run: async (p, ctx) => {
|
||||
@@ -235,7 +239,8 @@ export const actions = [
|
||||
readOnly: true,
|
||||
params: {
|
||||
user_id: f.uint(),
|
||||
message_id: f.int({ min: 0 }).default(0),
|
||||
// Signed int32 hash, frequently negative — see get_group_msg_history.
|
||||
message_id: f.int().default(0),
|
||||
count: f.int({ min: 0 }).default(20),
|
||||
},
|
||||
run: async (p, ctx) => {
|
||||
|
||||
Reference in new issue
Block a user