app
components
data
functions
api
admin-apps
appeals
[id]
_middleware.ts
accept.ts
ban.ts
deny.ts
_middleware.ts
submit.ts
toggle.ts
auth
game-appeals
gme
inactivity
mod-queue
reports
uploads
_middleware.ts
gcloud.ts
permissions.ts
roblox-open-cloud.ts
public
.gitignore
.node-version
OFL.txt
emotion-server.js
index.css
index.d.ts
package-lock.json
package.json
remix.config.js
server.ts
theme.ts
tsconfig.json
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
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 new Response('{"error":"Forbidden"}', {
|
|
headers: {
|
|
"content-type": "application/json",
|
|
},
|
|
status: 403,
|
|
});
|
|
|
|
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 new Response('{"error":"No appeal with that ID exists"}', {
|
|
headers: {
|
|
"content-type": "application/json",
|
|
},
|
|
status: 404,
|
|
});
|
|
|
|
context.data.appeal = key;
|
|
}
|
|
|
|
if (
|
|
body.feedback &&
|
|
(typeof body.feedback !== "string" || body.feedback.length > 512)
|
|
)
|
|
return new Response('{"error":"Invalid feedback"}', {
|
|
headers: {
|
|
"content-type": "application/json",
|
|
},
|
|
status: 400,
|
|
});
|
|
|
|
return await context.next();
|
|
}
|