app
components
data
functions
api
admin-apps
appeals
[id]
_middleware.ts
accept.ts
ban.ts
deny.ts
_middleware.ts
bans.ts
submit.ts
toggle.ts
auth
data-transfers
events-team
game-appeals
game-bans
gme
inactivity
infractions
me
mod-queue
reports
uploads
[[path]].ts
coconut.ts
events.ts
webview-captcha.ts
_middleware.ts
common.ts
email.ts
gcloud.ts
permissions.ts
roblox-open-cloud.ts
upload.ts
public
.gitignore
.node-version
.prettierignore
OFL.txt
README.md
emotion-server.js
index.css
index.d.ts
package-lock.json
package.json
remix.config.js
server.ts
theme.ts
tsconfig.json
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { jsonError } from "../../../common.js";
|
|
|
|
export async function onRequestPost(context: RequestContext) {
|
|
const { pathname } = new URL(context.request.url);
|
|
|
|
// Fix weirdo routing issue
|
|
if (pathname.endsWith("/submit") || pathname.endsWith("/toggle"))
|
|
return await context.next();
|
|
|
|
const { permissions } = context.data.current_user;
|
|
|
|
if (!(permissions & (1 << 0)) && !(permissions & (1 << 11)))
|
|
return jsonError("Forbidden", 403);
|
|
|
|
if (pathname.endsWith("/bans")) return await context.next();
|
|
|
|
const { body } = context.data;
|
|
const id = context.params.id as string;
|
|
|
|
context.data.targetId = id;
|
|
|
|
if (!pathname.endsWith("/ban")) {
|
|
const key = await context.env.DATA.get(`appeal_${id}`);
|
|
|
|
if (!key) return jsonError("No appeal with that ID exists", 404);
|
|
|
|
context.data.appeal = JSON.parse(key);
|
|
}
|
|
|
|
if (
|
|
body.feedback &&
|
|
(typeof body.feedback !== "string" || body.feedback.length > 512)
|
|
)
|
|
return jsonError("Invalid feedback", 400);
|
|
|
|
return await context.next();
|
|
}
|