mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
fix: align PR button custom_id with parser, secure token deletion, load zh locale
This commit is contained in:
parent
589558a20d
commit
9f875e3180
3 changed files with 9 additions and 4 deletions
|
|
@ -84,11 +84,12 @@ export function formatPullRequest(
|
|||
});
|
||||
}
|
||||
|
||||
const actionable = pr.state === "open" && !!repo && pr.number != null;
|
||||
const [repoOwner, repoName] = (repo ?? "/").split("/", 2);
|
||||
const actionable = pr.state === "open" && !!repoOwner && !!repoName && pr.number != null;
|
||||
const actions: NeutralAction[] | undefined = actionable
|
||||
? [
|
||||
{ id: `ghpr|merge|${repo}|${pr.number}`, label: "合并", style: "primary" },
|
||||
{ id: `ghpr|close|${repo}|${pr.number}`, label: "关闭", style: "danger" },
|
||||
{ id: `ghpr|merge|${repoOwner}|${repoName}|${pr.number}`, label: "合并", style: "primary" },
|
||||
{ id: `ghpr|close|${repoOwner}|${repoName}|${pr.number}`, label: "关闭", style: "danger" },
|
||||
]
|
||||
: undefined;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { en } from "./locales/en";
|
||||
import { zh } from "./locales/zh";
|
||||
|
||||
type NestedStrings = { [key: string]: string | NestedStrings };
|
||||
export type Translations = NestedStrings;
|
||||
|
|
@ -26,6 +27,7 @@ export async function loadTranslations(
|
|||
kv?: { get<T>(key: string, type: "json"): Promise<T | null> },
|
||||
): Promise<Translations> {
|
||||
if (lang === "en") return en;
|
||||
if (lang === "zh") return zh;
|
||||
|
||||
const cached = cache.get(lang);
|
||||
if (cached) return cached;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Hono } from "hono";
|
||||
import { getOAuthURL, handleOAuthCallback } from "../github/oauth";
|
||||
import { removeToken, saveDiscordLink, saveTelegramLink } from "../github/store";
|
||||
import { createAdminSession, adminCookie } from "./session";
|
||||
import { createAdminSession, adminCookie, getAdminSession } from "./session";
|
||||
import { loadGroups, resolveScope, hasAnyAccess } from "./groups";
|
||||
import { sendMessage } from "../drivers/telegram/rest";
|
||||
import type { Env } from "../types";
|
||||
|
|
@ -127,6 +127,8 @@ export function createOAuthRoutes(): Hono<{ Bindings: Env }> {
|
|||
});
|
||||
|
||||
app.delete("/token/:userId", async (c) => {
|
||||
const session = await getAdminSession(c.env.KV, c.req.header("Cookie"));
|
||||
if (!session) return c.json({ error: "Unauthorized" }, 401);
|
||||
await removeToken(c.env.KV, c.req.param("userId"));
|
||||
return c.json({ ok: true });
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue