app
components
data
functions
api
admin-apps
appeals
auth
data-transfers
events-team
game-appeals
game-bans
gme
inactivity
infractions
mod-queue
reports
[id]
complete.ts
recall.ts
submit.ts
uploads
_middleware.ts
common.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
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { jsonError } from "../../common.js";
|
|
|
|
export async function onRequestPost(context: RequestContext) {
|
|
const { id } = context.data.body;
|
|
|
|
if (!id) return jsonError("No ID provided", 400);
|
|
|
|
const user = await context.env.DATA.get(`reportprocessing_${id}`);
|
|
|
|
if (
|
|
!user ||
|
|
(context.data.current_user
|
|
? user !== context.data.current_user.id
|
|
: user !== context.request.headers.get("CF-Connecting-IP"))
|
|
)
|
|
return jsonError("No report with that ID is processing", 404);
|
|
|
|
await context.env.DATA.delete(`reportprocessing_${id}`);
|
|
|
|
const value = await context.env.DATA.get(`report_${id}`);
|
|
|
|
if (!value) return jsonError("Report is missing", 500);
|
|
|
|
if (context.env.REPORTS_WEBHOOK) {
|
|
await fetch(context.env.REPORTS_WEBHOOK, {
|
|
body: JSON.stringify({
|
|
embeds: [
|
|
{
|
|
title: "Report Submitted",
|
|
color: 3756250,
|
|
description: `View this report at https://carcrushers.cc/mod-queue?id=${id}&type=report`,
|
|
},
|
|
],
|
|
}),
|
|
headers: {
|
|
"content-type": "application/json",
|
|
},
|
|
method: "POST",
|
|
});
|
|
}
|
|
|
|
return new Response(null, {
|
|
status: 204,
|
|
});
|
|
}
|