fix(onebot): get_rkey_server fails on empty rkey set; document rename return

Adversarial Wave 2 pass (no blockers): get_rkey_server now returns
ACTION_FAILED instead of an 'expired_time=now, no keys' shell when no
download rkey is available, so a caching caller can't misread 'unavailable'
as 'valid-but-expired'. Added an empty-list test. Annotated rename_group_file's
{ok:true} body as a deliberate NapCat-parity deviation from sibling file ops.
This commit is contained in:
DrSmoothl committed 2026-06-18 00:26:34 +08:00
1 parent 7625c18768
commit f936515a59
3 files changed
+14

No files matched your search

+6
View File
@@ -1230,6 +1230,12 @@ export const actions = [
{ rkey?: string; ttl?: number } | undefined;
const priv = pick(10);
const group = pick(20);
// No rkey at all → fail rather than hand back an "expired_time = now,
// no keys" shell that a caching caller would misread as a valid-but-empty
// (already-expired) result.
if (!priv?.rkey && !group?.rkey) {
return failedResponse(RETCODE.ACTION_FAILED, 'no download rkey available');
}
const ttls = [priv?.ttl, group?.ttl].filter((t): t is number => typeof t === 'number' && t > 0);
const minTtl = ttls.length ? Math.min(...ttls) : 0;
const data: JsonObject = {
@@ -112,6 +112,8 @@ export const actions = [
},
run: async (p, ctx) => {
await ctx.bridge.apis.groupFile.rename(p.group_id, p.file_id, p.current_parent_directory || '/', p.new_name);
// {ok:true} 刻意对齐 NapCat RenameGroupFile 的返回体,偏离 SnowLuma 同类
// 文件写操作(move/delete 返回空 data)——为 NapCat 客户端 drop-in 兼容。
return okResponse({ ok: true });
},
}),