koishi-plugin-best-cave 2.4.3 → 2.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +10 -5
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -558,15 +558,20 @@ ${pendingCaves.map((c) => c.id).join("|")}`;
|
|
|
558
558
|
const createPendAction = /* @__PURE__ */ __name((actionType) => async ({ session }, ...ids) => {
|
|
559
559
|
const adminError = requireAdmin(session);
|
|
560
560
|
if (adminError) return adminError;
|
|
561
|
-
|
|
561
|
+
let idsToProcess = ids;
|
|
562
|
+
if (idsToProcess.length === 0) {
|
|
563
|
+
const pendingCaves = await this.ctx.database.get("cave", { status: "pending" }, { fields: ["id"] });
|
|
564
|
+
if (!pendingCaves.length) return "当前没有需要审核的回声洞";
|
|
565
|
+
idsToProcess = pendingCaves.map((c) => c.id);
|
|
566
|
+
}
|
|
562
567
|
try {
|
|
563
568
|
const targetStatus = actionType === "approve" ? "active" : "delete";
|
|
564
569
|
const actionText = actionType === "approve" ? "通过" : "拒绝";
|
|
565
570
|
const cavesToProcess = await this.ctx.database.get("cave", {
|
|
566
|
-
id: { $in:
|
|
571
|
+
id: { $in: idsToProcess },
|
|
567
572
|
status: "pending"
|
|
568
573
|
});
|
|
569
|
-
if (cavesToProcess.length === 0) return `回声洞(${
|
|
574
|
+
if (cavesToProcess.length === 0) return `回声洞(${idsToProcess.join("|")})无需审核或不存在`;
|
|
570
575
|
const processedIds = cavesToProcess.map((cave2) => cave2.id);
|
|
571
576
|
await this.ctx.database.upsert("cave", processedIds.map((id) => ({ id, status: targetStatus })));
|
|
572
577
|
if (targetStatus === "delete") cleanupPendingDeletions(this.ctx, this.fileManager, this.logger, this.reusableIds);
|
|
@@ -576,8 +581,8 @@ ${pendingCaves.map((c) => c.id).join("|")}`;
|
|
|
576
581
|
return `操作失败: ${error.message}`;
|
|
577
582
|
}
|
|
578
583
|
}, "createPendAction");
|
|
579
|
-
pend.subcommand(".Y [...ids:posint]", "通过审核").usage("通过一个或多个指定 ID
|
|
580
|
-
pend.subcommand(".N [...ids:posint]", "拒绝审核").usage("拒绝一个或多个指定 ID
|
|
584
|
+
pend.subcommand(".Y [...ids:posint]", "通过审核").usage("通过一个或多个指定 ID 的回声洞审核。若不指定 ID,则通过所有待审核的回声洞。").action(createPendAction("approve"));
|
|
585
|
+
pend.subcommand(".N [...ids:posint]", "拒绝审核").usage("拒绝一个或多个指定 ID 的回声洞审核。若不指定 ID,则拒绝所有待审核的回声洞。").action(createPendAction("reject"));
|
|
581
586
|
}
|
|
582
587
|
/**
|
|
583
588
|
* @description 将新回声洞提交到管理群组以供审核。
|