Added simpler avatar URL field.

This commit is contained in:
Pachira 2024-11-22 20:57:02 +00:00
parent 39be84fcc0
commit b2301dde45

View file

@ -35,24 +35,12 @@ final class UsersRpcHandler implements RpcHandler {
$colourRaw = null;
$colourCSS = (string)$colour;
} else {
// Index doesn't have a proper toRawRGB func???
$colourRaw = Colour::toMisuzu($colour) & 0xFFFFFF;
$colourRaw = Colour::toRawRgb($colour);
$colourCSS = (string)ColourRgb::convert($colour);
}
$baseUrl = $this->siteInfo->getURL();
$avatars = [];
$formatAvatarUrl = fn($res = 0) => (
$baseUrl . $this->urls->format('user-avatar', ['user' => $userInfo->getId(), 'res' => $res])
);
$avatars[] = ['res' => 0, 'url' => $formatAvatarUrl()];
foreach(UserAvatarAsset::DIMENSIONS as $res)
$avatars[] = ['res' => $res, 'url' => $formatAvatarUrl($res)];
$avatars = array_reverse($avatars);
$output = [];
$output['id'] = $userInfo->getId();
@ -83,7 +71,22 @@ final class UsersRpcHandler implements RpcHandler {
$output['last_active_at'] = $userInfo->getLastActiveAt()->toIso8601ZuluString();
$output['profile_url'] = $baseUrl . $this->urls->format('user-profile', ['user' => $userInfo->getId()]);
$output['avatar_url'] = $baseUrl . $this->urls->format('user-avatar', ['user' => $userInfo->getId()]);
/* Remove the following later */
$avatars = [];
$formatAvatarUrl = fn($res = 0) => (
$baseUrl . $this->urls->format('user-avatar', ['user' => $userInfo->getId(), 'res' => $res])
);
$avatars[] = ['res' => 0, 'url' => $formatAvatarUrl()];
foreach(UserAvatarAsset::DIMENSIONS as $res)
$avatars[] = ['res' => $res, 'url' => $formatAvatarUrl($res)];
$avatars = array_reverse($avatars);
$output['avatar_urls'] = $avatars;
/* / */
if($userInfo->isDeleted())
$output['is_deleted'] = true;