Move to V2 datastore apis

This commit is contained in:
2026-03-31 03:24:13 -04:00
parent b69b5cb4eb
commit e3af1e4f37
8 changed files with 36 additions and 53 deletions

View File

@@ -49,9 +49,7 @@ export async function onRequestGet(context: RequestContext) {
let banList; let banList;
try { try {
banList = (await getBanList(context)) as { banList = (await getBanList(context)).value;
[k: string]: { BanType: number };
};
} catch { } catch {
return jsonError("Failed to create data transfer request", 500); return jsonError("Failed to create data transfer request", 500);
} }

View File

@@ -15,15 +15,7 @@ export async function onRequestPost(context: RequestContext) {
if (!appeal) return jsonError("Appeal not found", 400); if (!appeal) return jsonError("Appeal not found", 400);
const banList = (await getBanList(context)) as { const { etag, path, value: banList } = await getBanList(context);
[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 = ?;") await context.env.D1.prepare("DELETE FROM game_appeals WHERE id = ?;")
.bind(context.params.id) .bind(context.params.id)
@@ -67,7 +59,7 @@ export async function onRequestPost(context: RequestContext) {
) )
.run(); .run();
await setBanList(context, banList); await setBanList(context, banList, etag);
return new Response(null, { return new Response(null, {
status: 204, status: 204,

View File

@@ -24,13 +24,7 @@ export default async function (
let banList; let banList;
try { try {
banList = (await getBanList(context)) as { banList = (await getBanList(context)).value;
[k: number]: {
BanType: number;
hidden_from_leaderboards?: boolean;
serverconfigurator_blacklist?: boolean;
};
};
} catch { } catch {
return { return {
error: "Failed to check your ban status", error: "Failed to check your ban status",

View File

@@ -33,13 +33,7 @@ export async function onRequestGet(context: RequestContext) {
let banList; let banList;
try { try {
banList = (await getBanList(context)) as { banList = (await getBanList(context)).value;
[k: number]: {
BanType: number;
hidden_from_leaderboards?: boolean;
serverconfigurator_blacklist?: boolean;
};
};
} catch (e) { } catch (e) {
console.log(e); console.log(e);

View File

@@ -31,12 +31,10 @@ export async function onRequestPost(context: RequestContext) {
) )
.run(); .run();
const banList = (await getBanList(context)) as { const { etag, path, value: banList } = await getBanList(context);
[k: string]: { BanType: number };
};
delete banList[user]; delete banList[user];
await setBanList(context, banList); await setBanList(context, banList, etag);
return new Response(null, { return new Response(null, {
status: 204, status: 204,

View File

@@ -78,15 +78,9 @@ export async function onRequestPost(context: RequestContext) {
await context.env.D1.batch(batchedQueries); await context.env.D1.batch(batchedQueries);
const banList = (await getBanList(context)) as { const { etag, path, value: banList } = await getBanList(context);
[k: string]: {
BanType: number;
hidden_from_leaderboards?: boolean;
serverconfigurator_blacklist?: boolean;
};
};
await setBanList(context, Object.assign(banList, newActions)); await setBanList(context, Object.assign(banList, newActions), etag);
} }
const pushNotificationData: Record<string, string> | null = const pushNotificationData: Record<string, string> | null =

View File

@@ -1,8 +1,8 @@
const DATASTORE_URL = const DATASTORE_URL =
"https://apis.roblox.com/datastores/v1/universes/274816972/standard-datastores/datastore/entries/entry?datastoreName=BanData&entryKey=CloudBanList"; "https://apis.roblox.com/cloud/v2/universes/274816972/data-stores/BanData/entries/CloudBanList";
const SAVE_DATA_URL = const SAVE_DATA_URL =
"https://apis.roblox.com/datastores/v1/universes/274816972/standard-datastores/datastore/entries/entry?datastoreName=RealData&entryKey="; "https://apis.roblox.com/cloud/v2/universes/274816972/data-stores/RealData/entries";
export async function getBanList(context: RequestContext) { export async function getBanList(context: RequestContext) {
const data = await fetch(DATASTORE_URL, { const data = await fetch(DATASTORE_URL, {
@@ -16,14 +16,26 @@ export async function getBanList(context: RequestContext) {
throw new Error("Failed to retrieve ban list"); throw new Error("Failed to retrieve ban list");
} }
return await data.json(); return (await data.json()) as {
etag: string;
path: string;
value: {
[k: string]: {
BanType: number;
hidden_from_leaderboards?: boolean;
serverconfigurator_blacklist?: boolean;
Unbanned?: boolean;
UnbanReduct?: number;
};
};
};
} }
export async function getSaveData( export async function getSaveData(
context: RequestContext, context: RequestContext,
user: number, user: number,
): Promise<string> { ): Promise<string> {
const data = await fetch(`${SAVE_DATA_URL}${user}`, { const data = await fetch(`${SAVE_DATA_URL}/${user}`, {
headers: { headers: {
"x-api-key": context.env.ROBLOX_OPENCLOUD_KEY, "x-api-key": context.env.ROBLOX_OPENCLOUD_KEY,
}, },
@@ -34,20 +46,21 @@ export async function getSaveData(
throw new Error(`Failed to retrieve save data for ${user}`); throw new Error(`Failed to retrieve save data for ${user}`);
} }
return await data.json(); return ((await data.json()) as { value: string }).value;
} }
export async function setBanList( export async function setBanList(
context: RequestContext, context: RequestContext,
data: { [k: string]: { [k: string]: any } }, value: any,
etag?: string,
) { ) {
const setRequest = await fetch(DATASTORE_URL, { const setRequest = await fetch(DATASTORE_URL, {
body: JSON.stringify(data), body: JSON.stringify(etag, value),
headers: { headers: {
"content-type": "application/json", "content-type": "application/json",
"x-api-key": context.env.ROBLOX_OPENCLOUD_KEY, "x-api-key": context.env.ROBLOX_OPENCLOUD_KEY,
}, },
method: "POST", method: "PATCH",
}); });
if (!setRequest.ok) { if (!setRequest.ok) {

View File

@@ -17,11 +17,11 @@
"@remix-run/cloudflare": "^2.17.4", "@remix-run/cloudflare": "^2.17.4",
"@remix-run/cloudflare-pages": "^2.17.4", "@remix-run/cloudflare-pages": "^2.17.4",
"@remix-run/react": "^2.17.4", "@remix-run/react": "^2.17.4",
"@sentry/cloudflare": "^10.43.0", "@sentry/cloudflare": "^10.46.0",
"@sentry/remix": "^10.43.0", "@sentry/remix": "^10.46.0",
"aws4fetch": "^1.0.20", "aws4fetch": "^1.0.20",
"dayjs": "^1.11.19", "dayjs": "^1.11.20",
"framer-motion": "^12.35.2", "framer-motion": "^12.38.0",
"react": "^18.3.1", "react": "^18.3.1",
"react-big-calendar": "^1.19.4", "react-big-calendar": "^1.19.4",
"react-dom": "^18.3.1" "react-dom": "^18.3.1"
@@ -34,10 +34,10 @@
"@types/react-dom": "^18.3.7", "@types/react-dom": "^18.3.7",
"dotenv": "^17.3.1", "dotenv": "^17.3.1",
"prettier": "^3.8.1", "prettier": "^3.8.1",
"typescript": "^5.9.3" "typescript": "^6.0.2"
}, },
"overrides": { "overrides": {
"@cloudflare/workers-types": "^4.20260310.1" "@cloudflare/workers-types": "^4.20260329.1"
}, },
"prettier": { "prettier": {
"endOfLine": "auto" "endOfLine": "auto"