Send back appeal types in metadata response
This commit is contained in:
@ -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 };
|
||||
}
|
||||
|
Reference in New Issue
Block a user