Greatly reduce repeated code

This commit is contained in:
2023-10-19 16:50:48 -04:00
parent 47e639be43
commit dd2d9f2672
34 changed files with 196 additions and 481 deletions

View File

@ -1,5 +1,6 @@
import { insertLogs } from "../../../gcloud.js";
import { getBanList, setBanList } from "../../../roblox-open-cloud.js";
import { insertLogs } from "../../../gcloud.js";
import { jsonError } from "../../../common.js";
export async function onRequestPost(context: RequestContext) {
const { ticket_link } = context.data.body;
@ -9,22 +10,11 @@ export async function onRequestPost(context: RequestContext) {
/^https?:\/\/carcrushers\.modmail\.dev\/logs\/[a-z\d]{12}$/,
)
)
return new Response('{"error":"Invalid ticket link provided"}', {
headers: {
"content-type": "application/json",
},
status: 400,
});
return jsonError("Invalid ticket link provided", 400);
const user = context.params.user as string;
if (isNaN(parseInt(user)))
return new Response('{"error":"Invalid user ID"}', {
headers: {
"content-type": "application/json",
},
status: 400,
});
if (isNaN(parseInt(user))) return jsonError("Invalid user ID", 400);
await insertLogs({ [user]: 3 }, ticket_link, context);