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) {
|
export async function onRequestPost(context: RequestContext) {
|
||||||
if (
|
if (
|
||||||
context.request.headers.get("rbx-auth") !==
|
context.request.headers.get("rbx-auth") !== context.env.ROBLOX_APPEALS_TOKEN
|
||||||
context.env.ROBLOX_APPEALS_TOKEN
|
|
||||||
)
|
)
|
||||||
return jsonError("Unauthorized", 401);
|
return jsonError("Unauthorized", 401);
|
||||||
|
|
||||||
@ -16,7 +15,7 @@ export async function onRequestPost(context: RequestContext) {
|
|||||||
|
|
||||||
if (precheckData.error) return jsonError(precheckData.error, 500);
|
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 (
|
export default async function (
|
||||||
context: RequestContext,
|
context: RequestContext,
|
||||||
user: number,
|
user: number,
|
||||||
): Promise<{ can_appeal?: boolean; error?: string; reason?: string }> {
|
): Promise<{
|
||||||
|
can_appeal?: boolean;
|
||||||
|
error?: string;
|
||||||
|
reason?: string;
|
||||||
|
types?: string[];
|
||||||
|
}> {
|
||||||
if (
|
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)
|
.bind(user)
|
||||||
.first()
|
.first()
|
||||||
)
|
)
|
||||||
@ -18,7 +25,11 @@ export default async function (
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
banList = (await getBanList(context)) as {
|
banList = (await getBanList(context)) as {
|
||||||
[k: number]: { BanType: number };
|
[k: number]: {
|
||||||
|
BanType: number;
|
||||||
|
hidden_from_leaderboards?: boolean;
|
||||||
|
serverconfigurator_blacklist?: boolean;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
} catch {
|
} catch {
|
||||||
return {
|
return {
|
||||||
@ -42,24 +53,20 @@ export default async function (
|
|||||||
).toLocaleString()} to submit another appeal`,
|
).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 {
|
if (userLogs.error)
|
||||||
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 {
|
|
||||||
return {
|
return {
|
||||||
error: "Could not determine your eligibility",
|
error: "Could not determine your eligibility",
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
// Legacy bans
|
// 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;
|
const allowedTime = (userLogs.results[0].executed_at as number) + 2592000000;
|
||||||
|
|
||||||
@ -71,5 +78,12 @@ export default async function (
|
|||||||
).toLocaleString()} to submit an appeal`,
|
).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