Skip to content
Permalink
Newer
Older
100644 56 lines (45 sloc) 1.55 KB
October 19, 2023 16:49
1
import { getBanList, setBanList } from "../../../roblox-open-cloud.js";
October 19, 2023 16:50
2
import { jsonError } from "../../../common.js";
October 19, 2023 16:49
3
4
export async function onRequestPost(context: RequestContext) {
5
const { statsReduction } = context.data.body;
6
7
if (statsReduction && typeof statsReduction !== "number")
October 19, 2023 16:50
8
return jsonError("Invalid stat reduction", 400);
October 19, 2023 16:49
9
10
const appeal: Record<string, any> | null = await context.env.D1.prepare(
11
"SELECT * FROM game_appeals WHERE id = ?;",
12
)
13
.bind(context.params.id)
14
.first();
October 19, 2023 16:49
15
October 19, 2023 16:50
16
if (!appeal) return jsonError("Appeal not found", 400);
October 19, 2023 16:49
17
18
const banList = (await getBanList(context)) as {
19
[k: string]: { BanType: number; Unbanned?: boolean; UnbanReduct?: number };
20
};
21
22
await context.env.DATA.delete(`gameappeal_${context.params.id as string}`);
23
await context.env.D1.prepare("DELETE FROM game_appeals WHERE id = ?;")
24
.bind(context.params.id)
25
.run();
October 19, 2023 16:49
26
27
if (!banList[appeal.roblox_id])
October 19, 2023 16:49
28
return new Response(null, {
29
status: 204,
30
});
31
32
banList[appeal.roblox_id] = {
October 19, 2023 16:49
33
BanType: 0,
34
Unbanned: true,
35
UnbanReduct: statsReduction,
36
};
37
38
await context.env.D1.prepare(
39
"INSERT INTO game_mod_logs (action, evidence, executed_at, executor, id, target) VALUES (?, ?, ?, ?, ?, ?);",
40
)
41
.bind(
42
"accept_appeal",
43
`https://carcrushers.cc/mod-queue?id=${context.params.id}&type=gma`,
44
Date.now(),
45
context.data.current_user.id,
46
crypto.randomUUID(),
47
appeal.roblox_id,
48
)
49
.run();
50
October 19, 2023 16:49
51
await setBanList(context, banList);
52
53
return new Response(null, {
54
status: 204,
55
});
56
}