Migrate the rest of the easy stuff
This commit is contained in:
@@ -7,19 +7,25 @@ export async function onRequestPost(context: RequestContext) {
|
||||
if (statsReduction && typeof statsReduction !== "number")
|
||||
return jsonError("Invalid stat reduction", 400);
|
||||
|
||||
const appeal: Record<string, any> | null = await context.env.D1.prepare(
|
||||
"SELECT * FROM game_appeals WHERE id = ?;",
|
||||
)
|
||||
.bind(context.params.id)
|
||||
.first();
|
||||
const appeal = await context.data.prisma.gameAppeal.findUnique({
|
||||
select: {
|
||||
roblox_id: true,
|
||||
type: true,
|
||||
},
|
||||
where: {
|
||||
id: context.params.id as string,
|
||||
},
|
||||
});
|
||||
|
||||
if (!appeal) return jsonError("Appeal not found", 400);
|
||||
|
||||
const { etag, value: banList } = await getBanList(context);
|
||||
|
||||
await context.env.D1.prepare("DELETE FROM game_appeals WHERE id = ?;")
|
||||
.bind(context.params.id)
|
||||
.run();
|
||||
await context.data.prisma.gameAppeal.delete({
|
||||
where: {
|
||||
id: context.params.id as string,
|
||||
},
|
||||
});
|
||||
|
||||
if (!banList[appeal.roblox_id]?.BanType)
|
||||
return new Response(null, {
|
||||
@@ -46,18 +52,15 @@ export async function onRequestPost(context: RequestContext) {
|
||||
};
|
||||
}
|
||||
|
||||
await context.env.D1.prepare(
|
||||
"INSERT INTO game_mod_logs (action, evidence, executed_at, executor, id, target) VALUES (?, ?, ?, ?, ?, ?);",
|
||||
)
|
||||
.bind(
|
||||
`accept appeal | ${banList[appeal.roblox_id]?.BanType === 2 ? "ban" : appeal.type}`,
|
||||
`https://carcrushers.cc/mod-queue?id=${context.params.id}&type=gma`,
|
||||
Date.now(),
|
||||
context.data.current_user.id,
|
||||
crypto.randomUUID(),
|
||||
appeal.roblox_id,
|
||||
)
|
||||
.run();
|
||||
await context.data.prisma.gameModLog.create({
|
||||
data: {
|
||||
action: `accept appeal | ${banList[appeal.roblox_id]?.BanType === 2 ? "ban" : appeal.type}`,
|
||||
evidence: `https://carcrushers.cc/mod-queue?id=${context.params.id}&type=gma`,
|
||||
executor: context.data.current_user.id,
|
||||
id: crypto.randomUUID(),
|
||||
target: appeal.roblox_id,
|
||||
},
|
||||
});
|
||||
|
||||
await setBanList(context, banList, etag);
|
||||
|
||||
|
||||
@@ -2,18 +2,22 @@ import { jsonError } from "../../../common.js";
|
||||
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
const appealId = context.params.id as string;
|
||||
|
||||
const appeal = await context.env.D1.prepare(
|
||||
"SELECT * FROM game_appeals WHERE id = ?;",
|
||||
)
|
||||
.bind(appealId)
|
||||
.first();
|
||||
const appeal = await context.data.prisma.gameAppeal.findUnique({
|
||||
select: {
|
||||
roblox_id: true,
|
||||
},
|
||||
where: {
|
||||
id: appealId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!appeal) return jsonError("Appeal not found", 404);
|
||||
|
||||
await context.env.D1.prepare("DELETE FROM game_appeals WHERE id = ?;")
|
||||
.bind(appealId)
|
||||
.run();
|
||||
await context.data.prisma.gameAppeal.delete({
|
||||
where: {
|
||||
id: appealId,
|
||||
},
|
||||
});
|
||||
|
||||
await context.env.DATA.put(
|
||||
`gameappealblock_${appeal.roblox_id}`,
|
||||
|
||||
Reference in New Issue
Block a user