feat: migrate send logs and discord links to D1

This commit is contained in:
RhenCloud committed 2026-08-03 05:18:58 +08:00
1 parent 5a98e45544
commit 3a6a2cbbc5
16 files changed
+139 -79

No files matched your search

+2 -2
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 });
+1 -1
View File
@@ -83,7 +83,7 @@ export function createOAuthRoutes(): Hono<{ Bindings: Env }> {
// Discord account-linking flow: bind the Discord user to this GitHub account.
if (pending.discordUserId) {
await saveDiscordLink(c.env.KV, pending.discordUserId, result.userId);
await saveDiscordLink(c.env.DB, pending.discordUserId, result.userId);
const isBrowserLink = (c.req.header("accept") ?? "").includes("text/html");
if (isBrowserLink) {
return c.html(linkedPage(result.login));