Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
We do a little API instability
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 1123b86 commit a5bf9fc
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions functions/api/game-bans/[user]/history.ts
Expand Up @@ -26,14 +26,29 @@ export async function onRequestGet(context: RequestContext) {

if (!users.length) return jsonError("No user found with that name", 400);

return jsonResponse(
JSON.stringify(
(await queryLogs(users[0].id, context)).sort((a, b) =>
a.entity.properties.executed_at.integerValue >
b.entity.properties.executed_at.integerValue
? 1
: -1,
),
),
const thumbnailRequest = await fetch(
`https://thumbnails.roblox.com/v1/users/avatar?format=Png&size=250x250&userIds=${users[0].id}`,
);

const response = {
history: (await queryLogs(users[0].id, context)).sort((a, b) =>
a.entity.properties.executed_at.integerValue >
b.entity.properties.executed_at.integerValue
? 1
: -1,
),
user: {
avatar: thumbnailRequest.ok
? (
(await thumbnailRequest.json()) as {
data: { imageUrl: string }[];
}
).data[0].imageUrl
: null,
id: users[0].id,
name: users[0].name,
},
};

return jsonResponse(JSON.stringify(response));
}

0 comments on commit a5bf9fc

Please sign in to comment.