mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-20 17:13:49 +00:00
feat: migrate send logs and discord links to D1
This commit is contained in:
16 files changed
+139
-79
No files matched your search
@@ -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 });
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in new issue
Block a user