diff --git a/functions/api/reports/[id]/action.ts b/functions/api/reports/[id]/action.ts index ecf1932..1497f72 100644 --- a/functions/api/reports/[id]/action.ts +++ b/functions/api/reports/[id]/action.ts @@ -14,22 +14,30 @@ export async function onRequestPost(context: RequestContext) { if (!report) return jsonError("Report does not exist", 404); const actionMap = context.data.body; - const newActions: { [k: string]: { BanType: number } } = {}; + const newActions: { + [k: string]: { + BanType: number; + hidden_from_leaderboards?: boolean; + serverconfigurator_blacklist?: boolean; + }; + } = {}; const logMap: { [k: string]: number } = {}; const user = JSON.parse(report.user); - for (const [user, action] of Object.entries(actionMap)) { + for (let [user, action] of Object.entries(actionMap)) { if ( isNaN(parseInt(user)) || typeof action !== "number" || action < 0 || - action > 2 + action > 3 ) return jsonError("Invalid action map", 400); if (action === 0) continue; - newActions[user] = { BanType: action }; + newActions[user] = { + BanType: action, + }; logMap[user] = action; } @@ -41,9 +49,11 @@ export async function onRequestPost(context: RequestContext) { const actionMap: { [k: number]: string } = { 1: "blacklist", 2: "ban", + 3: "server config block", }; for (const [k, v] of Object.entries(logMap)) { + // If ignore action if (v === 0) continue; batchedQueries.push( @@ -56,12 +66,24 @@ export async function onRequestPost(context: RequestContext) { parseInt(k), ), ); + + // If not a ban action + if (v === 1) { + newActions[user].hidden_from_leaderboards = true; + } else if (v === 3) { + newActions[user].serverconfigurator_blacklist = true; + newActions[user].BanType = 1; + } } await context.env.D1.batch(batchedQueries); const banList = (await getBanList(context)) as { - [k: string]: { BanType: number }; + [k: string]: { + BanType: number; + hidden_from_leaderboards?: boolean; + serverconfigurator_blacklist?: boolean; + }; }; await setBanList(context, Object.assign(banList, newActions));