ework-web 0.10.72 → 0.10.73
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/package.json +1 -1
- package/src/index.ts +15 -16
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -589,6 +589,21 @@ async function handle(req: Request, url: URL, ip: string, ctx: { authed: boolean
|
|
|
589
589
|
// /api/* routes since those would 404 on /api/v1/* paths. The shim reuses
|
|
590
590
|
// the existing ctx.user (cookie or PAT auth already resolved above).
|
|
591
591
|
if (url.pathname.startsWith("/api/v1/")) {
|
|
592
|
+
if (url.pathname === "/api/v1/dispatch-state" && req.method === "GET") {
|
|
593
|
+
const owner = url.searchParams.get("owner") ?? "";
|
|
594
|
+
const repo = url.searchParams.get("repo") ?? "";
|
|
595
|
+
const number = url.searchParams.get("number") ?? "";
|
|
596
|
+
if (!owner || !repo || !number) return json({ error: "owner, repo, number required" }, 400);
|
|
597
|
+
const project = await getProject(owner, repo);
|
|
598
|
+
if (!project) return json({ dispatchOff: false, aiStatus: "" });
|
|
599
|
+
const issue = await getIssueWithMeta(project.id, Number(number));
|
|
600
|
+
const cfgKv = await getConfigAll();
|
|
601
|
+
const globalOff = cfgKv["dispatchEnabled"] === "false";
|
|
602
|
+
const projectOff = cfgKv[`dispatchOff:${owner}/${repo}`] === "1";
|
|
603
|
+
const aiStatus = issue?.ai_status ?? "";
|
|
604
|
+
const issueOff = aiStatus === "dispatch_off" || aiStatus === "halted";
|
|
605
|
+
return json({ dispatchOff: globalOff || projectOff || issueOff, aiStatus });
|
|
606
|
+
}
|
|
592
607
|
const evStatus = url.pathname.match(/^\/api\/v1\/repos\/([^/]+)\/([^/]+)\/issues\/(\d+)\/status$/);
|
|
593
608
|
if (evStatus && req.method === "POST") {
|
|
594
609
|
const [, owner, repo, numStr] = evStatus;
|
|
@@ -1351,22 +1366,6 @@ async function handle(req: Request, url: URL, ip: string, ctx: { authed: boolean
|
|
|
1351
1366
|
}
|
|
1352
1367
|
}
|
|
1353
1368
|
|
|
1354
|
-
if (url.pathname === "/api/v1/dispatch-state" && req.method === "GET") {
|
|
1355
|
-
const owner = url.searchParams.get("owner") ?? "";
|
|
1356
|
-
const repo = url.searchParams.get("repo") ?? "";
|
|
1357
|
-
const number = url.searchParams.get("number") ?? "";
|
|
1358
|
-
if (!owner || !repo || !number) return json({ error: "owner, repo, number required" }, 400);
|
|
1359
|
-
const project = await getProject(owner, repo);
|
|
1360
|
-
if (!project) return json({ dispatchOff: false, aiStatus: "" });
|
|
1361
|
-
const issue = await getIssueWithMeta(project.id, Number(number));
|
|
1362
|
-
const cfgKv = await getConfigAll();
|
|
1363
|
-
const globalOff = cfgKv["dispatchEnabled"] === "false";
|
|
1364
|
-
const projectOff = cfgKv[`dispatchOff:${owner}/${repo}`] === "1";
|
|
1365
|
-
const aiStatus = issue?.ai_status ?? "";
|
|
1366
|
-
const issueOff = aiStatus === "dispatch_off" || aiStatus === "halted";
|
|
1367
|
-
return json({ dispatchOff: globalOff || projectOff || issueOff, aiStatus });
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
1369
|
if (url.pathname === "/api/router/strategy") {
|
|
1371
1370
|
if (!ctx.user || ctx.user.is_admin !== 1) return json({ error: "admin required" }, 403);
|
|
1372
1371
|
const routerUrl = cfg.daemonWebhookUrl.replace(/\/$/, "");
|