mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
feat(admin): add detailed send log viewer with extended fields
This commit is contained in:
parent
3a6a2cbbc5
commit
dcbe93be91
14 changed files with 460 additions and 42 deletions
|
|
@ -8,7 +8,7 @@ import {
|
|||
type AdminSession,
|
||||
} from "./session";
|
||||
import { loadGroups, saveGroups, resolveScope, hasAnyAccess, type AccessScope } from "./groups";
|
||||
import { getSendLog } from "../lib/send-log";
|
||||
import { getSendLog, getSendLogById } from "../lib/send-log";
|
||||
import { log } from "../lib/log";
|
||||
|
||||
const VALID_FILTER_TYPES = new Set(["event", "repo", "actor", "action", "branch", "keyword"]);
|
||||
|
|
@ -239,6 +239,23 @@ export function createAdminRoutes(): Hono<{ Bindings: Env }> {
|
|||
return c.json({ logs });
|
||||
});
|
||||
|
||||
app.get("/api/logs/:id", async (c) => {
|
||||
const s = await loadScope(c);
|
||||
if (!s) return c.json({ error: "Unauthorized" }, 401);
|
||||
const id = Number(c.req.param("id"));
|
||||
if (!Number.isInteger(id) || id <= 0) return c.json({ error: "Invalid log id" }, 400);
|
||||
const entry = await getSendLogById(c.env.DB, id);
|
||||
if (!entry) return c.json({ error: "Log entry not found" }, 404);
|
||||
if (!s.scope.isSuper) {
|
||||
const all = await loadRoutes(c.env.KV);
|
||||
const route = all.find((r) => r.id === entry.routeId);
|
||||
if (!route?.groupId || !s.scope.groupIds.has(route.groupId)) {
|
||||
return c.json({ error: "Forbidden" }, 403);
|
||||
}
|
||||
}
|
||||
return c.json({ log: entry });
|
||||
});
|
||||
|
||||
app.put("/api/routes", async (c) => {
|
||||
const s = await loadScope(c);
|
||||
if (!s) return c.json({ error: "Unauthorized" }, 401);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue