mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
feat: migrate send logs and discord links to D1
This commit is contained in:
parent
5a98e45544
commit
3a6a2cbbc5
16 changed files with 139 additions and 79 deletions
|
|
@ -227,13 +227,13 @@ export function createAdminRoutes(): Hono<{ Bindings: Env }> {
|
|||
if (!s) return c.json({ error: "Unauthorized" }, 401);
|
||||
const limit = Math.min(Math.max(Number(c.req.query("limit") ?? 50), 1), 100);
|
||||
if (s.scope.isSuper) {
|
||||
return c.json({ logs: await getSendLog(c.env.KV, limit) });
|
||||
return c.json({ logs: await getSendLog(c.env.DB, limit) });
|
||||
}
|
||||
const all = await loadRoutes(c.env.KV);
|
||||
const allowed = new Set(
|
||||
all.filter((r) => r.groupId != null && s.scope.groupIds.has(r.groupId)).map((r) => r.id),
|
||||
);
|
||||
const logs = (await getSendLog(c.env.KV, 200))
|
||||
const logs = (await getSendLog(c.env.DB, 200))
|
||||
.filter((l) => allowed.has(l.routeId))
|
||||
.slice(0, limit);
|
||||
return c.json({ logs });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue