feat: migrate send logs and discord links to D1

This commit is contained in:
RhenCloud 2026-08-03 03:57:58 +08:00
parent 5a98e45544
commit 3a6a2cbbc5
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
16 changed files with 139 additions and 79 deletions

View file

@ -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 });