Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Create game appeal endpoints
- Loading branch information
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { insertLogs } from "../../../gcloud.js"; | ||
import { getBanList, setBanList } from "../../../roblox-open-cloud.js"; | ||
|
||
export async function onRequestPost(context: RequestContext) { | ||
const { statsReduction } = context.data.body; | ||
|
||
if (statsReduction && typeof statsReduction !== "number") | ||
return new Response('{"error":"Invalid stat reduction"}', { | ||
headers: { | ||
"content-type": "application/json", | ||
}, | ||
status: 400, | ||
}); | ||
|
||
const appeal = await context.env.DATA.get( | ||
`gameappeal_${context.params.id as string}` | ||
); | ||
|
||
if (!appeal) | ||
return new Response('{"error":"Appeal not found"}', { | ||
headers: { | ||
"content-type": "application/json", | ||
}, | ||
status: 404, | ||
}); | ||
|
||
const data = JSON.parse(appeal); | ||
const banList = (await getBanList(context)) as { | ||
[k: string]: { BanType: number; Unbanned?: boolean; UnbanReduct?: number }; | ||
}; | ||
|
||
await context.env.DATA.delete(`gameappeal_${context.params.id as string}`); | ||
|
||
if (!banList[data.roblox_id]) | ||
return new Response(null, { | ||
status: 204, | ||
}); | ||
|
||
banList[data.roblox_id] = { | ||
BanType: 0, | ||
Unbanned: true, | ||
UnbanReduct: statsReduction, | ||
}; | ||
|
||
await insertLogs( | ||
{ [data.roblox_id]: 4 }, | ||
context.params.id as string, | ||
context | ||
); | ||
await setBanList(context, banList); | ||
|
||
return new Response(null, { | ||
status: 204, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export async function onRequestPost(context: RequestContext) { | ||
const appealId = context.params.id as string; | ||
|
||
const appeal = await context.env.DATA.get(`gameappeal_${appealId}`); | ||
|
||
if (!appeal) | ||
return new Response('{"error":"Appeal not found"}', { | ||
headers: { | ||
"content-type": "application/json", | ||
}, | ||
status: 404, | ||
}); | ||
|
||
const appealData = JSON.parse(appeal); | ||
|
||
await context.env.DATA.delete(`gameappeal_${appealId}`); | ||
await context.env.DATA.put( | ||
`gameappealblock_${appealData.roblox_id}`, | ||
`${Date.now() + 2592000000}`, | ||
{ expirationTtl: 2592000000 } | ||
); | ||
|
||
return new Response(null, { | ||
status: 204, | ||
}); | ||
} |