Compare commits
4 Commits
7c7701f406
...
41f361fcf1
| Author | SHA1 | Date | |
|---|---|---|---|
|
41f361fcf1
|
|||
|
513234bbe6
|
|||
|
5ba59ff596
|
|||
|
bcd07299c5
|
@@ -84,6 +84,10 @@ export default function (props: GameAppealProps & { port?: MessagePort }) {
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<Stack divider={<StackDivider />}>
|
||||
<Box>
|
||||
<Heading size="xs">Appeal Type</Heading>
|
||||
<Text>{props.type}</Text>
|
||||
</Box>
|
||||
<Box>
|
||||
<Heading size="xs">Response: Explanation of Ban</Heading>
|
||||
<Text>{props.what_happened}</Text>
|
||||
|
||||
@@ -16,29 +16,49 @@ export async function onRequestPost(context: RequestContext) {
|
||||
if (!appeal) return jsonError("Appeal not found", 400);
|
||||
|
||||
const banList = (await getBanList(context)) as {
|
||||
[k: string]: { BanType: number; Unbanned?: boolean; UnbanReduct?: number };
|
||||
[k: string]: {
|
||||
BanType: number;
|
||||
hidden_from_leaderboards?: boolean;
|
||||
serverconfigurator_blacklist?: boolean;
|
||||
Unbanned?: boolean;
|
||||
UnbanReduct?: number;
|
||||
};
|
||||
};
|
||||
|
||||
await context.env.D1.prepare("DELETE FROM game_appeals WHERE id = ?;")
|
||||
.bind(context.params.id)
|
||||
.run();
|
||||
|
||||
if (!banList[appeal.roblox_id])
|
||||
if (!banList[appeal.roblox_id]?.BanType)
|
||||
return new Response(null, {
|
||||
status: 204,
|
||||
});
|
||||
|
||||
banList[appeal.roblox_id] = {
|
||||
BanType: 0,
|
||||
Unbanned: true,
|
||||
UnbanReduct: statsReduction,
|
||||
};
|
||||
if (banList[appeal.roblox_id].BanType === 2) {
|
||||
banList[appeal.roblox_id] = {
|
||||
BanType: 0,
|
||||
Unbanned: true,
|
||||
UnbanReduct: statsReduction,
|
||||
};
|
||||
} else if (appeal.type === "server configurator") {
|
||||
banList[appeal.roblox_id] = {
|
||||
...banList[appeal.roblox_id],
|
||||
serverconfigurator_blacklist: false,
|
||||
};
|
||||
} else if (appeal.type === "blacklist") {
|
||||
banList[appeal.roblox_id] = {
|
||||
...banList[appeal.roblox_id],
|
||||
hidden_from_leaderboards: false,
|
||||
Unbanned: true,
|
||||
UnbanReduct: statsReduction,
|
||||
};
|
||||
}
|
||||
|
||||
await context.env.D1.prepare(
|
||||
"INSERT INTO game_mod_logs (action, evidence, executed_at, executor, id, target) VALUES (?, ?, ?, ?, ?, ?);",
|
||||
)
|
||||
.bind(
|
||||
"accept_appeal",
|
||||
`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,
|
||||
|
||||
@@ -3,8 +3,7 @@ import precheck from "./precheck.js";
|
||||
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
if (
|
||||
context.request.headers.get("rbx-auth") !==
|
||||
context.env.ROBLOX_APPEALS_TOKEN
|
||||
context.request.headers.get("rbx-auth") !== context.env.ROBLOX_APPEALS_TOKEN
|
||||
)
|
||||
return jsonError("Unauthorized", 401);
|
||||
|
||||
@@ -16,7 +15,7 @@ export async function onRequestPost(context: RequestContext) {
|
||||
|
||||
if (precheckData.error) return jsonError(precheckData.error, 500);
|
||||
|
||||
const { can_appeal, reason } = precheckData;
|
||||
const { can_appeal, reason, types } = precheckData;
|
||||
|
||||
return jsonResponse(JSON.stringify({ can_appeal, reason }));
|
||||
return jsonResponse(JSON.stringify({ can_appeal, reason, types }));
|
||||
}
|
||||
|
||||
@@ -3,9 +3,16 @@ import { getBanList } from "../../roblox-open-cloud.js";
|
||||
export default async function (
|
||||
context: RequestContext,
|
||||
user: number,
|
||||
): Promise<{ can_appeal?: boolean; error?: string; reason?: string }> {
|
||||
): Promise<{
|
||||
can_appeal?: boolean;
|
||||
error?: string;
|
||||
reason?: string;
|
||||
types?: string[];
|
||||
}> {
|
||||
if (
|
||||
await context.env.D1.prepare("SELECT * FROM game_appeals WHERE roblox_id = ?;")
|
||||
await context.env.D1.prepare(
|
||||
"SELECT * FROM game_appeals WHERE roblox_id = ?;",
|
||||
)
|
||||
.bind(user)
|
||||
.first()
|
||||
)
|
||||
@@ -18,7 +25,11 @@ export default async function (
|
||||
|
||||
try {
|
||||
banList = (await getBanList(context)) as {
|
||||
[k: number]: { BanType: number };
|
||||
[k: number]: {
|
||||
BanType: number;
|
||||
hidden_from_leaderboards?: boolean;
|
||||
serverconfigurator_blacklist?: boolean;
|
||||
};
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
@@ -42,24 +53,20 @@ export default async function (
|
||||
).toLocaleString()} to submit another appeal`,
|
||||
};
|
||||
|
||||
let userLogs;
|
||||
const userLogs = await context.env.D1.prepare(
|
||||
"SELECT executed_at FROM game_mod_logs WHERE target = ? ORDER BY executed_at DESC;",
|
||||
)
|
||||
.bind(user)
|
||||
.all();
|
||||
|
||||
try {
|
||||
userLogs = await context.env.D1.prepare(
|
||||
"SELECT executed_at FROM game_mod_logs WHERE target = ? ORDER BY executed_at DESC;",
|
||||
)
|
||||
.bind(user)
|
||||
.all();
|
||||
|
||||
if (userLogs.error) throw new Error("Query failed");
|
||||
} catch {
|
||||
if (userLogs.error)
|
||||
return {
|
||||
error: "Could not determine your eligibility",
|
||||
};
|
||||
}
|
||||
|
||||
// Legacy bans
|
||||
if (!userLogs.results.length) return { can_appeal: true, reason: "" };
|
||||
if (!userLogs.results.length)
|
||||
return { can_appeal: true, reason: "", types: ["ban"] };
|
||||
|
||||
const allowedTime = (userLogs.results[0].executed_at as number) + 2592000000;
|
||||
|
||||
@@ -71,5 +78,12 @@ export default async function (
|
||||
).toLocaleString()} to submit an appeal`,
|
||||
};
|
||||
|
||||
return { can_appeal: true, reason: "" };
|
||||
const types: string[] = [];
|
||||
|
||||
if (banList[user].BanType) types.push("ban");
|
||||
if (banList[user].hidden_from_leaderboards) types.push("leaderboard");
|
||||
if (banList[user].serverconfigurator_blacklist)
|
||||
types.push("server_configurator");
|
||||
|
||||
return { can_appeal: true, reason: "", types };
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@ export async function onRequestPost(context: RequestContext) {
|
||||
if (authHeader !== context.env.ROBLOX_APPEALS_TOKEN)
|
||||
return jsonError("Unauthorized", 401);
|
||||
|
||||
const { id, reasonForUnban, username, whatHappened } = context.data.body;
|
||||
const { id, reasonForUnban, type, username, whatHappened } =
|
||||
context.data.body;
|
||||
|
||||
if (
|
||||
typeof id !== "number" ||
|
||||
typeof reasonForUnban !== "string" ||
|
||||
!["ban", "leaderboard", "server_configurator"].includes(type) ||
|
||||
typeof username !== "string" ||
|
||||
typeof whatHappened !== "string"
|
||||
)
|
||||
@@ -48,9 +50,17 @@ export async function onRequestPost(context: RequestContext) {
|
||||
}${Date.now()}`;
|
||||
|
||||
await context.env.D1.prepare(
|
||||
"INSERT INTO game_appeals (created_at, id, reason_for_unban, roblox_id, roblox_username, what_happened) VALUES (?, ?, ?, ?, ?, ?);",
|
||||
"INSERT INTO game_appeals (created_at, id, reason_for_unban, roblox_id, roblox_username, type, what_happened) VALUES (?, ?, ?, ?, ?, ?, ?);",
|
||||
)
|
||||
.bind(Date.now(), appealId, reasonForUnban, id, username, whatHappened)
|
||||
.bind(
|
||||
Date.now(),
|
||||
appealId,
|
||||
reasonForUnban,
|
||||
id,
|
||||
username,
|
||||
type,
|
||||
whatHappened,
|
||||
)
|
||||
.run();
|
||||
|
||||
await fetch(context.env.REPORTS_WEBHOOK, {
|
||||
|
||||
@@ -34,7 +34,11 @@ export async function onRequestGet(context: RequestContext) {
|
||||
|
||||
try {
|
||||
banList = (await getBanList(context)) as {
|
||||
[k: number]: { BanType: number };
|
||||
[k: number]: {
|
||||
BanType: number;
|
||||
hidden_from_leaderboards?: boolean;
|
||||
serverconfigurator_blacklist?: boolean;
|
||||
};
|
||||
};
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
@@ -47,8 +51,17 @@ export async function onRequestGet(context: RequestContext) {
|
||||
const banData = banList[users[0].id];
|
||||
|
||||
if (!banData?.BanType) current_status = "Not Moderated";
|
||||
else if (banData.BanType === 1) current_status = "Hidden from Leaderboards";
|
||||
else if (banData.BanType === 2) current_status = "Banned";
|
||||
else if (banData.BanType === 1) {
|
||||
if (
|
||||
banData.hidden_from_leaderboards &&
|
||||
banData.serverconfigurator_blacklist
|
||||
)
|
||||
current_status = "Hidden / Server Config Blocked";
|
||||
else if (banData.hidden_from_leaderboards)
|
||||
current_status = "Hidden From Leaderboards";
|
||||
else if (banData.serverconfigurator_blacklist)
|
||||
current_status = "Server Config Blocked";
|
||||
} else if (banData.BanType === 2) current_status = "Banned";
|
||||
|
||||
const response = {
|
||||
history: (
|
||||
|
||||
3
index.d.ts
vendored
3
index.d.ts
vendored
@@ -15,7 +15,7 @@ declare global {
|
||||
event_id: string;
|
||||
event_type: string;
|
||||
token: string;
|
||||
}
|
||||
};
|
||||
|
||||
type RequestContext = EventContext<Env, string, { [k: string]: any }>;
|
||||
|
||||
@@ -39,6 +39,7 @@ declare global {
|
||||
reason_for_unban: string;
|
||||
roblox_id: number;
|
||||
roblox_username: string;
|
||||
type: string;
|
||||
what_happened: string;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user