stnh70 commited on
Commit
fe005d5
·
verified ·
1 Parent(s): d67b997

Update thunderapi/thunderapi.ts

Browse files
Files changed (1) hide show
  1. thunderapi/thunderapi.ts +41 -5
thunderapi/thunderapi.ts CHANGED
@@ -2482,26 +2482,62 @@ apiRouter.post("/file_batch_share", async (ctx) => {
2482
  });
2483
 
2484
  // 转存分享文件
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2485
  apiRouter.post("/restore", async (ctx) => {
2486
  if (!ensureClient(ctx)) return;
2487
 
2488
  try {
2489
- // 解析请求体
2490
  const requestBody = await ctx.request.body.json();
2491
 
2492
- // 提取必要参数
2493
  const shareId = requestBody.share_id;
2494
  const passCodeToken = requestBody.pass_code_token || null;
2495
- const fileIds = requestBody.file_ids || null;
 
 
 
 
 
 
2496
 
2497
- // 验证必要参数
2498
  if (!shareId) {
2499
  ctx.response.status = Status.BadRequest;
2500
  ctx.response.body = { error: "share_id is required" };
2501
  return;
2502
  }
2503
 
2504
- // 调用PikPak API
2505
  const result = await withCaptchaRetry(
2506
  "GET:/drive/v1/share/restore",
2507
  () => THUNDERX_CLIENT.restore(shareId, passCodeToken, fileIds)
 
2482
  });
2483
 
2484
  // 转存分享文件
2485
+ // apiRouter.post("/restore", async (ctx) => {
2486
+ // if (!ensureClient(ctx)) return;
2487
+
2488
+ // try {
2489
+ // // 解析请求体
2490
+ // const requestBody = await ctx.request.body.json();
2491
+
2492
+ // // 提取必要参数
2493
+ // const shareId = requestBody.share_id;
2494
+ // const passCodeToken = requestBody.pass_code_token || null;
2495
+ // const fileIds = requestBody.file_ids || null;
2496
+
2497
+ // // 验证必要参数
2498
+ // if (!shareId) {
2499
+ // ctx.response.status = Status.BadRequest;
2500
+ // ctx.response.body = { error: "share_id is required" };
2501
+ // return;
2502
+ // }
2503
+
2504
+ // // 调用PikPak API
2505
+ // const result = await withCaptchaRetry(
2506
+ // "GET:/drive/v1/share/restore",
2507
+ // () => THUNDERX_CLIENT.restore(shareId, passCodeToken, fileIds)
2508
+ // );
2509
+
2510
+ // ctx.response.body = result;
2511
+ // } catch (error) {
2512
+ // console.error("转存分享文件失败:", error);
2513
+ // ctx.response.status = Status.InternalServerError;
2514
+ // ctx.response.body = { error: error.message };
2515
+ // }
2516
+ // });
2517
+
2518
  apiRouter.post("/restore", async (ctx) => {
2519
  if (!ensureClient(ctx)) return;
2520
 
2521
  try {
 
2522
  const requestBody = await ctx.request.body.json();
2523
 
 
2524
  const shareId = requestBody.share_id;
2525
  const passCodeToken = requestBody.pass_code_token || null;
2526
+ const fileIds = requestBody.file_ids || []; // 确保此参数被传递
2527
+
2528
+ console.log("转存请求参数:", {
2529
+ shareId,
2530
+ passCodeToken,
2531
+ fileIds: fileIds ? `${fileIds.length}个文件` : "无"
2532
+ });
2533
 
 
2534
  if (!shareId) {
2535
  ctx.response.status = Status.BadRequest;
2536
  ctx.response.body = { error: "share_id is required" };
2537
  return;
2538
  }
2539
 
2540
+ // 调用PikPak API,传递所有三个参数
2541
  const result = await withCaptchaRetry(
2542
  "GET:/drive/v1/share/restore",
2543
  () => THUNDERX_CLIENT.restore(shareId, passCodeToken, fileIds)