Return current_status property in history endpoint

This commit is contained in:
Regalijan 2023-10-22 17:23:31 -04:00
parent 62b418f0e5
commit a4524cfea4
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -1,3 +1,4 @@
import { getBanList } from "../../../roblox-open-cloud.js";
import { jsonError, jsonResponse } from "../../../common.js";
import { queryLogs } from "../../../gcloud.js";
@ -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,
@ -45,6 +66,7 @@ export async function onRequestGet(context: RequestContext) {
}
).data[0].imageUrl
: null,
current_status,
id: users[0].id,
name: users[0].name,
},