From b2301dde45368f74b515bccf5f55b3a81ccfbcbd Mon Sep 17 00:00:00 2001 From: flashwave Date: Fri, 22 Nov 2024 20:57:02 +0000 Subject: [PATCH] Added simpler avatar URL field. --- src/Users/UsersRpcHandler.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Users/UsersRpcHandler.php b/src/Users/UsersRpcHandler.php index 0010f7f..40c1319 100644 --- a/src/Users/UsersRpcHandler.php +++ b/src/Users/UsersRpcHandler.php @@ -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;