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:
3 files changed
+14
No files matched your search
@@ -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 });
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -744,4 +744,10 @@ describe('extended-actions / get_rkey_server', () => {
|
||||
expect(d.private_rkey).toBe('&rkey=PRIV');
|
||||
expect(d.group_rkey).toBeUndefined();
|
||||
});
|
||||
|
||||
it('fails (not an expired empty shell) when no rkey is available', async () => {
|
||||
const getDownloadRKeys = vi.fn(async () => []);
|
||||
const res = await makeHandler(fakeCtx(fakeBridge(), { getDownloadRKeys })).handle('get_rkey_server', {});
|
||||
expect(res).toMatchObject({ status: 'failed', retcode: 100 });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user