Create ban revocation endpoint
This commit is contained in:
parent
5557bebae9
commit
4d76aafaa4
41
functions/api/game-bans/[user]/revoke.ts
Normal file
41
functions/api/game-bans/[user]/revoke.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { insertLogs } from "../../../gcloud.js";
|
||||||
|
import { getBanList, setBanList } from "../../../roblox-open-cloud.js";
|
||||||
|
|
||||||
|
export async function onRequestPost(context: RequestContext) {
|
||||||
|
const { ticket_link } = context.data.body;
|
||||||
|
|
||||||
|
if (
|
||||||
|
!ticket_link?.match(
|
||||||
|
/^https?:\/\/carcrushers\.modmail\.dev\/logs\/[a-z\d]{12}$/
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return new Response('{"error":"Invalid ticket link provided"}', {
|
||||||
|
headers: {
|
||||||
|
"content-type": "application/json",
|
||||||
|
},
|
||||||
|
status: 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,
|
||||||
|
});
|
||||||
|
|
||||||
|
await insertLogs({ [user]: 3 }, ticket_link, context);
|
||||||
|
|
||||||
|
const banList = (await getBanList(context)) as {
|
||||||
|
[k: string]: { BanType: number };
|
||||||
|
};
|
||||||
|
|
||||||
|
delete banList[user];
|
||||||
|
await setBanList(context, banList);
|
||||||
|
|
||||||
|
return new Response(null, {
|
||||||
|
status: 204,
|
||||||
|
});
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user