Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Return current_status property in history endpoint
  • Loading branch information
regalijan committed Oct 22, 2023
1 parent 62b418f commit a4524cf
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion functions/api/game-bans/[user]/history.ts
@@ -1,3 +1,4 @@
import { getBanList } from "../../../roblox-open-cloud.js";
import { jsonError, jsonResponse } from "../../../common.js";
import { queryLogs } from "../../../gcloud.js";

Expand Down Expand Up @@ -30,9 +31,29 @@ export async function onRequestGet(context: RequestContext) {
`https://thumbnails.roblox.com/v1/users/avatar?format=Png&size=250x250&userIds=${users[0].id}`,
);

let banList;

try {
banList = (await getBanList(context)) as {
[k: number]: { BanType: number };
};
} catch (e) {
console.log(e);

return jsonError("Failed to check current moderation status", 500);
}

let current_status = "Unknown";

const banData = banList[users[0].id];

if (!banData?.BanType) current_status = "Not Moderated";
else if (banData.BanType === 1) current_status = "Hidden from Leaderboards";
else if (banData.BanType === 2) current_status = "Banned";

const response = {
history: (await queryLogs(users[0].id, context)).sort((a, b) =>
a.entity.properties.executed_at.integerValue >
a.entity.properties.executed_at.integerValue <
b.entity.properties.executed_at.integerValue
? 1
: -1,
Expand All @@ -45,6 +66,7 @@ export async function onRequestGet(context: RequestContext) {
}
).data[0].imageUrl
: null,
current_status,
id: users[0].id,
name: users[0].name,
},
Expand Down

0 comments on commit a4524cf

Please sign in to comment.