From 026d1ca06d09900cc692599dc787f27f9f23e84d Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:50:21 -0400 Subject: [PATCH] New formatting --- app/context.tsx | 2 +- app/entry.client.tsx | 2 +- app/entry.server.tsx | 6 +++--- app/root.tsx | 12 +++++------ app/routes/appeals.tsx | 2 +- components/AppealCard.tsx | 2 +- components/FormGenerator.tsx | 26 +++++++++++------------ components/GameAppealCard.tsx | 4 ++-- components/Navigation.tsx | 3 +++ components/NewInfractionModal.tsx | 2 +- emotion-server.js | 4 ++-- functions/_middleware.ts | 5 +---- functions/api/admin-apps/submit.ts | 2 +- functions/api/appeals/[id]/accept.ts | 4 ++-- functions/api/appeals/[id]/ban.ts | 2 +- functions/api/appeals/[id]/deny.ts | 2 +- functions/api/appeals/submit.ts | 8 +++---- functions/api/auth/oauth.ts | 4 ++-- functions/api/auth/session.ts | 8 +++---- functions/api/game-appeals/[id]/accept.ts | 4 ++-- functions/api/game-appeals/[id]/deny.ts | 2 +- functions/api/game-bans/[user]/history.ts | 8 +++---- functions/api/game-bans/[user]/revoke.ts | 2 +- functions/api/gme/add.ts | 2 +- functions/api/infractions/new.ts | 18 ++++++++-------- functions/api/mod-queue/list.ts | 2 +- functions/api/uploads/[[id]].ts | 6 +++--- functions/permissions.ts | 4 ++-- functions/roblox-open-cloud.ts | 2 +- index.d.ts | 2 +- 30 files changed, 76 insertions(+), 76 deletions(-) diff --git a/app/context.tsx b/app/context.tsx index e6a4abe..181a677 100644 --- a/app/context.tsx +++ b/app/context.tsx @@ -15,5 +15,5 @@ export interface ClientStyleContextData { } export const ClientStyleContext = createContext( - null + null, ); diff --git a/app/entry.client.tsx b/app/entry.client.tsx index 9ee3a56..f2f167f 100644 --- a/app/entry.client.tsx +++ b/app/entry.client.tsx @@ -34,5 +34,5 @@ hydrateRoot( - + , ); diff --git a/app/entry.server.tsx b/app/entry.server.tsx index 89fac37..a426ab5 100644 --- a/app/entry.server.tsx +++ b/app/entry.server.tsx @@ -10,7 +10,7 @@ export default function handleRequest( request: Request, responseStatusCode: number, responseHeaders: Headers, - remixContext: EntryContext + remixContext: EntryContext, ) { const cache = createEmotionCache(); const { extractCriticalToChunks } = createEmotionServer(cache); @@ -19,7 +19,7 @@ export default function handleRequest( - + , ); const chunks = extractCriticalToChunks(html); @@ -29,7 +29,7 @@ export default function handleRequest( - + , ); responseHeaders.set("content-type", "text/html;charset=utf-8"); diff --git a/app/root.tsx b/app/root.tsx index a9b8012..2a599a4 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -46,7 +46,7 @@ export function ErrorBoundary() { location.reload()}> Refresh - + , ); const { status } = error; @@ -74,7 +74,7 @@ export function ErrorBoundary() { history.go(-1)}> Go back - + , ); default: @@ -90,7 +90,7 @@ export function ErrorBoundary() { location.reload()}> Reload - + , ); } } @@ -124,7 +124,7 @@ export function meta() { function getMarkup( loaderData: { [k: string]: any }, - child: ReactNode + child: ReactNode, ): JSX.Element { const Document = withEmotionCache( ({ children }: { children: ReactNode }, emotionCache) => { @@ -149,7 +149,7 @@ function getMarkup( colorModeManager={cookieStorageManagerSSR( typeof document === "undefined" ? `chakra-ui-color-mode=${loaderData.theme}` - : document.cookie + : document.cookie, )} theme={theme} > @@ -199,7 +199,7 @@ function getMarkup( ); - } + }, ); return {child}; diff --git a/app/routes/appeals.tsx b/app/routes/appeals.tsx index 2bcbaf0..a5b9d0f 100644 --- a/app/routes/appeals.tsx +++ b/app/routes/appeals.tsx @@ -44,7 +44,7 @@ export async function loader({ context }: { context: RequestContext }) { await dataKV.list({ prefix: `appeal_${currentUser.id}`, }) - ).keys.length + ).keys.length, ), can_toggle: currentUser.permissions & (1 << 0) || currentUser.permissions & (1 << 11), diff --git a/components/AppealCard.tsx b/components/AppealCard.tsx index 9b3811e..d7f8d48 100644 --- a/components/AppealCard.tsx +++ b/components/AppealCard.tsx @@ -23,7 +23,7 @@ import { useEffect, useState } from "react"; export default function (props: AppealCardProps) { const [dateString, setDateString] = useState( - new Date(props.created_at).toUTCString() + new Date(props.created_at).toUTCString(), ); const [action, setAction] = useState(""); const [feedback, setFeedback] = useState(""); diff --git a/components/FormGenerator.tsx b/components/FormGenerator.tsx index 5aa2915..692dcaf 100644 --- a/components/FormGenerator.tsx +++ b/components/FormGenerator.tsx @@ -49,7 +49,7 @@ export default function ({ state: { [k: string]: string | string[] }, setState: Dispatch>, id: string, - value: string + value: string, ) { const newState = { ...state }; newState[id] = value; @@ -60,7 +60,7 @@ export default function ({ function renderCheckboxOptions( c: component, state: { [k: string]: string | string[] }, - setState: Dispatch> + setState: Dispatch>, ) { if (!c.options) throw new Error("Options for checkbox are undefined"); @@ -88,7 +88,7 @@ export default function ({ ? groupValues.push(e.target.value) : groupValues.splice( groupValues.findIndex((v) => v === e.target.value), - 1 + 1, ); newState[c.id] = groupValues; @@ -97,7 +97,7 @@ export default function ({ value={option.value} > {option.value} - + , ); } @@ -111,7 +111,7 @@ export default function ({ function renderRadioElements( c: component, state: { [k: string]: string | string[] }, - setState: Dispatch> + setState: Dispatch>, ) { if (!c.options) throw new Error("Options for radio buttons are undefined!"); const buttons = []; @@ -120,7 +120,7 @@ export default function ({ buttons.push( {option.value} - + , ); } @@ -142,7 +142,7 @@ export default function ({ function renderSelectElements( c: component, state: { [k: string]: string | string[] }, - setState: Dispatch> + setState: Dispatch>, ) { if (!c.options) throw new Error("Options for select are undefined!"); @@ -170,14 +170,14 @@ export default function ({ function generateReactComponents( components: component[], state: { [k: string]: string | string[] }, - setState: Dispatch> + setState: Dispatch>, ): JSX.Element[] { const fragmentsList = []; for (const component of components) { fragmentsList.push( {component.title}, -
+
, ); switch (component.type) { @@ -204,7 +204,7 @@ export default function ({ value={component.value} /> Field is required - + , ); break; @@ -212,7 +212,7 @@ export default function ({ fragmentsList.push( @@ -227,7 +227,7 @@ export default function ({ - + , ); break; @@ -256,7 +256,7 @@ export default function ({ style={{ display: page ? "none" : undefined }} > {generateReactComponents(componentList, responses, setResponses)} - + , ); } diff --git a/components/GameAppealCard.tsx b/components/GameAppealCard.tsx index 17e8b59..7009b4b 100644 --- a/components/GameAppealCard.tsx +++ b/components/GameAppealCard.tsx @@ -22,7 +22,7 @@ import { export default function (props: GameAppealProps) { async function performAction(action: "accept" | "deny"): Promise { const statsReduction = parseInt( - (document.getElementById("reductPercentage") as HTMLInputElement).value + (document.getElementById("reductPercentage") as HTMLInputElement).value, ); const actionResponse = await fetch(`/api/game-appeals/${props.roblox_id}`, { @@ -49,7 +49,7 @@ export default function (props: GameAppealProps) { duration: 10000, status: "error", title: "An error occurred...", - } + }, ); } diff --git a/components/Navigation.tsx b/components/Navigation.tsx index db86985..d8ae98c 100644 --- a/components/Navigation.tsx +++ b/components/Navigation.tsx @@ -112,6 +112,9 @@ export default function (props: { Support + + Community + void }) { if (!props.isOpen) return; const evidenceElement = document.getElementById( - "evidence" + "evidence", ) as HTMLInputElement; if (!evidenceElement.files && e.clipboardData?.files) { diff --git a/emotion-server.js b/emotion-server.js index 291cd88..02502d8 100644 --- a/emotion-server.js +++ b/emotion-server.js @@ -55,7 +55,7 @@ function createConstructStyleTagsFromChunks(cache, nonceString) { item.key, item.ids.join(" "), item.css, - nonceString + nonceString, ); }); @@ -73,7 +73,7 @@ export function createEmotionServer(cache) { extractCriticalToChunks: createExtractCriticalToChunks(cache), constructStyleTagsFromChunks: createConstructStyleTagsFromChunks( cache, - nonceString + nonceString, ), }; } diff --git a/functions/_middleware.ts b/functions/_middleware.ts index eaba7cf..500dea4 100644 --- a/functions/_middleware.ts +++ b/functions/_middleware.ts @@ -106,10 +106,7 @@ async function setHeaders(context: RequestContext) { "Content-Security-Policy", "connect-src: https://o1071757.ingest.sentry.io https://storage.googleapis.com self; default-src: self; frame-src: https://challenges.cloudflare.com; img-src: https://cdn.discordapp.com https://mediaproxy.carcrushers.cc self; media-src: https://mediaproxy.carcrushers.cc; report-uri: https://o1071757.ingest.sentry.io/api/6069431/security/?sentry_key=3d2b34700e6942f9b739cd8b2001f70f; script=src: https://challenges.cloudflare.com self", ); - response.headers.set( - "Permissions-Policy", - "clipboard-write=(self)", - ); + response.headers.set("Permissions-Policy", "clipboard-write=(self)"); response.headers.set("Referrer-Policy", "same-origin"); response.headers.set( "RTV", diff --git a/functions/api/admin-apps/submit.ts b/functions/api/admin-apps/submit.ts index ce320f7..4cccf7c 100644 --- a/functions/api/admin-apps/submit.ts +++ b/functions/api/admin-apps/submit.ts @@ -7,7 +7,7 @@ export async function onRequest(context: RequestContext) { }); const deliveryDate = new Date( - Date.now() + 86400000 + Math.round(Math.random() * 172800000) + Date.now() + 86400000 + Math.round(Math.random() * 172800000), ) .toUTCString() .replace("GMT", "+0000"); diff --git a/functions/api/appeals/[id]/accept.ts b/functions/api/appeals/[id]/accept.ts index 497a9a2..92aa033 100644 --- a/functions/api/appeals/[id]/accept.ts +++ b/functions/api/appeals/[id]/accept.ts @@ -15,7 +15,7 @@ export async function onRequestPost(context: RequestContext) { authorization: `Basic ${btoa("api:" + context.env.MAILGUN_API_KEY)}`, }, method: "POST", - } + }, ); if (!emailReq.ok) { @@ -38,7 +38,7 @@ export async function onRequestPost(context: RequestContext) { "x-audit-log-reason": `Appeal accepted by ${currentUser.username}#${currentUser.discriminator} (${currentUser.id})`, }, method: "DELETE", - } + }, ); await fetch(context.env.APPEALS_WEBHOOK, { diff --git a/functions/api/appeals/[id]/ban.ts b/functions/api/appeals/[id]/ban.ts index 72dbf83..b501f8d 100644 --- a/functions/api/appeals/[id]/ban.ts +++ b/functions/api/appeals/[id]/ban.ts @@ -11,7 +11,7 @@ export async function onRequestPost(context: RequestContext) { await context.env.DATA.put( `appealban_${context.data.targetId}`, - JSON.stringify({ moderator: currentUser.id }) + JSON.stringify({ moderator: currentUser.id }), ); await fetch(context.env.APPEALS_WEBHOOK, { body: JSON.stringify({ diff --git a/functions/api/appeals/[id]/deny.ts b/functions/api/appeals/[id]/deny.ts index 4c1d941..0029732 100644 --- a/functions/api/appeals/[id]/deny.ts +++ b/functions/api/appeals/[id]/deny.ts @@ -15,7 +15,7 @@ export async function onRequestPost(context: RequestContext) { authorization: `Basic ${btoa("api:" + context.env.MAILGUN_API_KEY)}`, }, method: "POST", - } + }, ); if (!emailReq.ok) { diff --git a/functions/api/appeals/submit.ts b/functions/api/appeals/submit.ts index 414ff3c..5422d96 100644 --- a/functions/api/appeals/submit.ts +++ b/functions/api/appeals/submit.ts @@ -19,7 +19,7 @@ export async function onRequestPost(context: RequestContext) { "content-type": "application/json", }, status: 400, - } + }, ); const { current_user: currentUser } = context.data; @@ -36,13 +36,13 @@ export async function onRequestPost(context: RequestContext) { prefix: `appeal_${currentUser.id}`, }); const existingBlockedAppeal = await context.env.DATA.get( - `blockedappeal_${currentUser.id}` + `blockedappeal_${currentUser.id}`, ); if ( existingBlockedAppeal || existingAppeals.keys.find( - (appeal) => (appeal.metadata as { [k: string]: any })?.open + (appeal) => (appeal.metadata as { [k: string]: any })?.open, ) ) return new Response('{"error":"Appeal already submitted"}', { @@ -82,7 +82,7 @@ export async function onRequestPost(context: RequestContext) { }), { expirationTtl: 94608000, - } + }, ); await fetch(context.env.APPEALS_WEBHOOK, { diff --git a/functions/api/auth/oauth.ts b/functions/api/auth/oauth.ts index bf56f49..f644ebe 100644 --- a/functions/api/auth/oauth.ts +++ b/functions/api/auth/oauth.ts @@ -14,7 +14,7 @@ export async function onRequestGet(context: RequestContext) { `https://discord.com/oauth2/authorize?client_id=${ env.DISCORD_ID }&redirect_uri=${encodeURIComponent( - `${protocol}//${host}/api/auth/session` - )}&response_type=code&scope=identify%20email%20guilds.members.read&state=${state}` + `${protocol}//${host}/api/auth/session`, + )}&response_type=code&scope=identify%20email%20guilds.members.read&state=${state}`, ); } diff --git a/functions/api/auth/session.ts b/functions/api/auth/session.ts index 7adaa65..08cc941 100644 --- a/functions/api/auth/session.ts +++ b/functions/api/auth/session.ts @@ -4,7 +4,7 @@ import tokenPrefixes from "../../../data/token_prefixes.json"; async function generateTokenHash(token: string): Promise { const hash = await crypto.subtle.digest( "SHA-512", - new TextEncoder().encode(token) + new TextEncoder().encode(token), ); return btoa(String.fromCharCode(...new Uint8Array(hash))) .replace(/\+/g, "-") @@ -62,7 +62,7 @@ export async function onRequestGet(context: RequestContext) { }).toString(), headers: { authorization: `Basic ${btoa( - context.env.DISCORD_ID + ":" + context.env.DISCORD_SECRET + context.env.DISCORD_ID + ":" + context.env.DISCORD_SECRET, )}`, "content-type": "application/x-www-form-urlencoded", }, @@ -114,7 +114,7 @@ export async function onRequestGet(context: RequestContext) { headers: { authorization: `Bearer ${tokenData.access_token}`, }, - } + }, ); const memberData: { [k: string]: any } = await serverMemberReq.json(); @@ -133,7 +133,7 @@ export async function onRequestGet(context: RequestContext) { selectedTokenStart + `${crypto.randomUUID()}${crypto.randomUUID()}${crypto.randomUUID()}${crypto.randomUUID()}`.replaceAll( "-", - "" + "", ); const tokenHash = await generateTokenHash(authToken); diff --git a/functions/api/game-appeals/[id]/accept.ts b/functions/api/game-appeals/[id]/accept.ts index d731833..8d2cd6a 100644 --- a/functions/api/game-appeals/[id]/accept.ts +++ b/functions/api/game-appeals/[id]/accept.ts @@ -13,7 +13,7 @@ export async function onRequestPost(context: RequestContext) { }); const appeal = await context.env.DATA.get( - `gameappeal_${context.params.id as string}` + `gameappeal_${context.params.id as string}`, ); if (!appeal) @@ -45,7 +45,7 @@ export async function onRequestPost(context: RequestContext) { await insertLogs( { [data.roblox_id]: 4 }, context.params.id as string, - context + context, ); await setBanList(context, banList); diff --git a/functions/api/game-appeals/[id]/deny.ts b/functions/api/game-appeals/[id]/deny.ts index f3fbb15..3c9eda1 100644 --- a/functions/api/game-appeals/[id]/deny.ts +++ b/functions/api/game-appeals/[id]/deny.ts @@ -17,7 +17,7 @@ export async function onRequestPost(context: RequestContext) { await context.env.DATA.put( `gameappealblock_${appealData.roblox_id}`, `${Date.now() + 2592000000}`, - { expirationTtl: 2592000000 } + { expirationTtl: 2592000000 }, ); return new Response(null, { diff --git a/functions/api/game-bans/[user]/history.ts b/functions/api/game-bans/[user]/history.ts index d3bd765..3cb44ca 100644 --- a/functions/api/game-bans/[user]/history.ts +++ b/functions/api/game-bans/[user]/history.ts @@ -11,7 +11,7 @@ export async function onRequestGet(context: RequestContext) { headers: { "content-type": "application/json", }, - } + }, ); if (!robloxUserReq.ok) { @@ -41,13 +41,13 @@ export async function onRequestGet(context: RequestContext) { a.entity.properties.executed_at.integerValue > b.entity.properties.executed_at.integerValue ? 1 - : -1 - ) + : -1, + ), ), { headers: { "content-type": "application/json", }, - } + }, ); } diff --git a/functions/api/game-bans/[user]/revoke.ts b/functions/api/game-bans/[user]/revoke.ts index cfc650c..ecf4fb6 100644 --- a/functions/api/game-bans/[user]/revoke.ts +++ b/functions/api/game-bans/[user]/revoke.ts @@ -6,7 +6,7 @@ export async function onRequestPost(context: RequestContext) { if ( !ticket_link?.match( - /^https?:\/\/carcrushers\.modmail\.dev\/logs\/[a-z\d]{12}$/ + /^https?:\/\/carcrushers\.modmail\.dev\/logs\/[a-z\d]{12}$/, ) ) return new Response('{"error":"Invalid ticket link provided"}', { diff --git a/functions/api/gme/add.ts b/functions/api/gme/add.ts index 20b4285..669b0c1 100644 --- a/functions/api/gme/add.ts +++ b/functions/api/gme/add.ts @@ -19,7 +19,7 @@ export async function onRequestPost(context: RequestContext) { if ( ["165594923586945025", "289372404541554689", "396347223736057866"].includes( - user + user, ) ) return new Response(null, { diff --git a/functions/api/infractions/new.ts b/functions/api/infractions/new.ts index 08bf741..0599a81 100644 --- a/functions/api/infractions/new.ts +++ b/functions/api/infractions/new.ts @@ -14,7 +14,7 @@ export async function onRequestPost(context: RequestContext) { if ( !context.data.current_user?.permissions || ![1 << 0, 1 << 2, 1 << 11].find( - (p) => context.data.current_user.permissions & p + (p) => context.data.current_user.permissions & p, ) ) return new Response('{"error":"Forbidden"}', { @@ -88,7 +88,7 @@ export async function onRequestPost(context: RequestContext) { }); const attachmentKey = `${Date.now()}${Math.round( - Math.random() * 10000000 + Math.random() * 10000000, ).toString()}/${file.name}`; urlPromises.push( @@ -96,8 +96,8 @@ export async function onRequestPost(context: RequestContext) { context.env, attachmentKey, file.size, - (allowedFileTypes.find((t) => t === file.type) as string).split("/")[1] - ) + (allowedFileTypes.find((t) => t === file.type) as string).split("/")[1], + ), ); } @@ -111,9 +111,9 @@ export async function onRequestPost(context: RequestContext) { status: 500, }); - const infractionId = `${body.get("user")}${Date.now()}${ - context.request.headers.get("cf-ray")?.split("-")[0] - }`; + const infractionId = `${body.get( + "user", + )}${Date.now()}${context.request.headers.get("cf-ray")?.split("-")[0]}`; const uploadReqs = []; for (let i = 0; i < files.length; i++) { @@ -121,7 +121,7 @@ export async function onRequestPost(context: RequestContext) { fetch(settledURLPromises[i] as unknown as string, { body: files[i], method: "PUT", - }) + }), ); } @@ -130,7 +130,7 @@ export async function onRequestPost(context: RequestContext) { JSON.stringify({ created_at: Date.now(), moderator: context.data.current_user.id, - }) + }), ); return new Response(null, { diff --git a/functions/api/mod-queue/list.ts b/functions/api/mod-queue/list.ts index 8a86a90..eae254a 100644 --- a/functions/api/mod-queue/list.ts +++ b/functions/api/mod-queue/list.ts @@ -54,7 +54,7 @@ export async function onRequestGet(context: RequestContext) { To avoid any potential injection attacks we enforce a list of specific values and permissions for table names */ await context.env.D1.prepare( - `SELECT id FROM ${table} WHERE created_at < ? AND open = ? ORDER BY created_at DESC LIMIT 25;` + `SELECT id FROM ${table} WHERE created_at < ? AND open = ? ORDER BY created_at DESC LIMIT 25;`, ) .bind(before, Number(!showClosed)) .all(); diff --git a/functions/api/uploads/[[id]].ts b/functions/api/uploads/[[id]].ts index d3e2fdf..4745958 100644 --- a/functions/api/uploads/[[id]].ts +++ b/functions/api/uploads/[[id]].ts @@ -8,18 +8,18 @@ export async function onRequestGet(context: RequestContext) { new TextEncoder().encode(atob(context.env.URL_SIGNING_KEY)), { hash: "SHA-1", name: "HMAC" }, false, - ["sign"] + ["sign"], ); const signature = await crypto.subtle.sign( "HMAC", signingKey, - new TextEncoder().encode(unsignedURL) + new TextEncoder().encode(unsignedURL), ); return Response.redirect( `${unsignedURL}&Signature=${btoa(new TextDecoder().decode(signature)) .replaceAll("+", "-") .replaceAll("/", "_") - .replaceAll("=", "")}` + .replaceAll("=", "")}`, ); } diff --git a/functions/permissions.ts b/functions/permissions.ts index c3b66f8..76504c3 100644 --- a/functions/permissions.ts +++ b/functions/permissions.ts @@ -1,7 +1,7 @@ export default async function ( userid: string, roles?: string[], - context?: RequestContext + context?: RequestContext, ): Promise { let permissions = 0; @@ -12,7 +12,7 @@ export default async function ( if (roles?.includes("607697704419852289")) permissions |= 1 << 4; // Events Team Management if ( ["165594923586945025", "289372404541554689", "396347223736057866"].includes( - userid + userid, ) || Boolean(await context?.env.DATA.get(`gamemod_${userid}`)) ) diff --git a/functions/roblox-open-cloud.ts b/functions/roblox-open-cloud.ts index 5b21277..c8f8b7c 100644 --- a/functions/roblox-open-cloud.ts +++ b/functions/roblox-open-cloud.ts @@ -18,7 +18,7 @@ export async function getBanList(context: RequestContext) { export async function setBanList( context: RequestContext, - data: { [k: string]: { [k: string]: any } } + data: { [k: string]: { [k: string]: any } }, ) { const setRequest = await fetch(DATASTORE_URL, { body: JSON.stringify(data), diff --git a/index.d.ts b/index.d.ts index 4c9aa8e..2ad137d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -17,7 +17,7 @@ declare global { interface EmotionServer { constructStyleTagsFromChunks: ( - criticalData: EmotionCriticalToChunks + criticalData: EmotionCriticalToChunks, ) => string; extractCriticalToChunks: (html: string) => EmotionCriticalToChunks; }