ework-web 0.10.56 → 0.10.57

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ework-web",
3
- "version": "0.10.56",
3
+ "version": "0.10.57",
4
4
  "type": "module",
5
5
  "description": "ework-web — standalone multi-project issue tracker. Local SQLite-backed, no external API dependency. Bun + TypeScript + SSR HTML.",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -1279,6 +1279,32 @@ async function handle(req: Request, url: URL, ip: string, ctx: { authed: boolean
1279
1279
  return json({ ok: true, enabled });
1280
1280
  }
1281
1281
 
1282
+ if (req.method === "GET" && url.pathname === "/api/wake-policy") {
1283
+ if (!ctx.user || ctx.user.is_admin !== 1) return json({ error: "admin required" }, 403);
1284
+ const cfg = await getConfigAll();
1285
+ const appCfg = await loadConfig();
1286
+ const list = (k: string, d: string) => (cfg[k] ?? d).split(",").map((s) => s.trim()).filter(Boolean);
1287
+ return json({
1288
+ wakeKinds: list("wakeKinds", "human"),
1289
+ wakeLogins: list("wakeLogins", ""),
1290
+ noWakeLogins: list("noWakeLogins", appCfg.daemonBotLogin),
1291
+ });
1292
+ }
1293
+
1294
+ if (req.method === "POST" && url.pathname === "/api/wake-policy") {
1295
+ if (!ctx.user || ctx.user.is_admin !== 1) return json({ error: "admin required" }, 403);
1296
+ const payload = await req.json().catch(() => ({} as Record<string, unknown>));
1297
+ const p = payload as { wakeKinds?: unknown; wakeLogins?: unknown; noWakeLogins?: unknown };
1298
+ const join = (v: unknown) => Array.isArray(v) ? v.filter((s) => typeof s === "string").join(",") : (typeof v === "string" ? v : "");
1299
+ const wk = join(p.wakeKinds);
1300
+ const wl = join(p.wakeLogins);
1301
+ const nw = join(p.noWakeLogins);
1302
+ if (wk) await setConfig("wakeKinds", wk); else await deleteConfig("wakeKinds");
1303
+ if (wl) await setConfig("wakeLogins", wl); else await deleteConfig("wakeLogins");
1304
+ if (nw) await setConfig("noWakeLogins", nw); else await deleteConfig("noWakeLogins");
1305
+ return json({ ok: true });
1306
+ }
1307
+
1282
1308
  if (url.pathname === "/api/router/daemons" && req.method === "GET") {
1283
1309
  if (!ctx.user || ctx.user.is_admin !== 1) return json({ error: "admin required" }, 403);
1284
1310
  try {
package/src/webhooks.ts CHANGED
@@ -695,8 +695,20 @@ export async function emitCommentEvent(
695
695
  log.info(`webhook: dispatch disabled but waking via comment_created (author=${comment.author}) for ${scopeKey}#${issue.number}`);
696
696
  }
697
697
  const authorUser = await getUserByLogin(comment.author);
698
- if (authorUser && authorUser.kind !== "human") {
699
- log.info(`webhook: comment wake denied (author=${comment.author} kind=${authorUser.kind}) for ${scopeKey}#${issue.number}`);
698
+ const appCfg = await loadConfig();
699
+ const cfgList = (k: string, d: string) =>
700
+ (cfg[k] ?? d).split(",").map((s) => s.trim()).filter(Boolean);
701
+ const noWake = cfgList("noWakeLogins", appCfg.daemonBotLogin);
702
+ const okLogins = cfgList("wakeLogins", "");
703
+ const okKinds = cfgList("wakeKinds", "human");
704
+ const author = comment.author;
705
+ const denied =
706
+ noWake.includes(author) ? "deny-list" :
707
+ okLogins.includes(author) ? null :
708
+ (authorUser && !okKinds.includes(authorUser.kind)) ? `kind=${authorUser.kind}` :
709
+ null;
710
+ if (denied) {
711
+ log.info(`webhook: comment wake denied (author=${author} reason=${denied}) for ${scopeKey}#${issue.number}`);
700
712
  return;
701
713
  }
702
714
  if (authorUser && !(await canWriteProject(projectId, { login: comment.author, is_admin: authorUser.is_admin }))) {