Return current_status property in history endpoint
This commit is contained in:
parent
62b418f0e5
commit
a4524cfea4
@ -1,3 +1,4 @@
|
|||||||
|
import { getBanList } from "../../../roblox-open-cloud.js";
|
||||||
import { jsonError, jsonResponse } from "../../../common.js";
|
import { jsonError, jsonResponse } from "../../../common.js";
|
||||||
import { queryLogs } from "../../../gcloud.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}`,
|
`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 = {
|
const response = {
|
||||||
history: (await queryLogs(users[0].id, context)).sort((a, b) =>
|
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
|
b.entity.properties.executed_at.integerValue
|
||||||
? 1
|
? 1
|
||||||
: -1,
|
: -1,
|
||||||
@ -45,6 +66,7 @@ export async function onRequestGet(context: RequestContext) {
|
|||||||
}
|
}
|
||||||
).data[0].imageUrl
|
).data[0].imageUrl
|
||||||
: null,
|
: null,
|
||||||
|
current_status,
|
||||||
id: users[0].id,
|
id: users[0].id,
|
||||||
name: users[0].name,
|
name: users[0].name,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user