mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-21 01:23:40 +00:00
chore: auto-fix lint & formatting [skip ci]
This commit is contained in:
1 parent
c73b642504
commit
89b43b8b28
12 files changed
+160
-97
No files matched your search
@@ -148,14 +148,7 @@ export function createActionRoutes(): Hono<AuthEnv> {
|
||||
repo: body.repo,
|
||||
issue_number: body.issueNumber,
|
||||
content: body.reaction as
|
||||
| "+1"
|
||||
| "-1"
|
||||
| "laugh"
|
||||
| "confused"
|
||||
| "heart"
|
||||
| "hooray"
|
||||
| "rocket"
|
||||
| "eyes",
|
||||
"+1" | "-1" | "laugh" | "confused" | "heart" | "hooray" | "rocket" | "eyes",
|
||||
});
|
||||
} catch (err) {
|
||||
log.error({ err }, "Failed to create reaction");
|
||||
|
||||
+7
-10
@@ -292,10 +292,7 @@ function ownerCount(members: GroupMember[]): number {
|
||||
}
|
||||
|
||||
/** Route params are always present for matched paths; keeps Hono's loose typing honest. */
|
||||
function param(
|
||||
c: { req: { param: (name: string) => string | undefined } },
|
||||
name: string,
|
||||
): string {
|
||||
function param(c: { req: { param: (name: string) => string | undefined } }, name: string): string {
|
||||
return c.req.param(name) ?? "";
|
||||
}
|
||||
|
||||
@@ -329,7 +326,9 @@ export function createAdminRoutes(): Hono<AuthEnv> {
|
||||
if (!token) return c.redirect("/admin");
|
||||
const auth = c.get("auth");
|
||||
if (!auth) {
|
||||
return c.redirect(`/auth/github?redirect=${encodeURIComponent(`/admin/invite?token=${token}`)}`);
|
||||
return c.redirect(
|
||||
`/auth/github?redirect=${encodeURIComponent(`/admin/invite?token=${token}`)}`,
|
||||
);
|
||||
}
|
||||
const result = await acceptInvite(c.env.KV, token, auth.session.userId, auth.session.login);
|
||||
if (result.ok) {
|
||||
@@ -411,10 +410,7 @@ export function createAdminRoutes(): Hono<AuthEnv> {
|
||||
);
|
||||
const otherOwner = ownerCount(members) > 1;
|
||||
if (!stillMine && !otherOwner) {
|
||||
return c.json(
|
||||
{ error: `group "${g.id}" would be left without an owner by you` },
|
||||
403,
|
||||
);
|
||||
return c.json({ error: `group "${g.id}" would be left without an owner by you` }, 403);
|
||||
}
|
||||
}
|
||||
nextAll = [
|
||||
@@ -453,7 +449,8 @@ export function createAdminRoutes(): Hono<AuthEnv> {
|
||||
if (prev.emoji !== g.emoji) fields.push("emoji");
|
||||
if (!deepEqual(prev.providers ?? [], g.providers ?? [])) fields.push("providers");
|
||||
if (!deepEqual(prev.owners ?? [], g.owners ?? [])) fields.push("owners");
|
||||
if (!deepEqual(prev.members ?? normalizeGroupMembers(prev), g.members)) fields.push("members");
|
||||
if (!deepEqual(prev.members ?? normalizeGroupMembers(prev), g.members))
|
||||
fields.push("members");
|
||||
if (fields.length > 0) {
|
||||
await recordAudit(c.env.DB, {
|
||||
ts: Date.now(),
|
||||
|
||||
+4
-4
@@ -62,9 +62,7 @@ export function currentAuth(c: Context<AuthEnv>): AuthContext {
|
||||
return c.get(AUTH_KEY);
|
||||
}
|
||||
|
||||
export type GroupAccess =
|
||||
| { ok: true; group: Group }
|
||||
| { ok: false; status: 403 | 404 };
|
||||
export type GroupAccess = { ok: true; group: Group } | { ok: false; status: 403 | 404 };
|
||||
|
||||
/** Resolves the group and checks the user can at least view it. */
|
||||
export function requireGroup(c: Context<AuthEnv>, groupId: string): GroupAccess {
|
||||
@@ -95,7 +93,9 @@ export function requireGroupRole(
|
||||
export { canEditGroup, canEditRoutes, roleAt };
|
||||
|
||||
/** Best-effort client IP for audit entries (Cloudflare header first). */
|
||||
export function clientIp(c: { req: { header: (n: string) => string | undefined } }): string | undefined {
|
||||
export function clientIp(c: {
|
||||
req: { header: (n: string) => string | undefined };
|
||||
}): string | undefined {
|
||||
return c.req.header("cf-connecting-ip") ?? c.req.header("x-forwarded-for")?.split(",")[0]?.trim();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user