From 51b6d29a3915dcb6cba7e3a8d0402f8b59051c41 Mon Sep 17 00:00:00 2001 From: flashwave Date: Fri, 3 Jan 2025 19:14:48 +0000 Subject: [PATCH] Alter output of /v1/me if banned. --- src/Users/UsersRpcHandler.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Users/UsersRpcHandler.php b/src/Users/UsersRpcHandler.php index 6798b33..b3ca8be 100644 --- a/src/Users/UsersRpcHandler.php +++ b/src/Users/UsersRpcHandler.php @@ -48,7 +48,6 @@ final class UsersRpcHandler implements RpcHandler { // TODO: there should be some kinda privacy controls for users - $rank = $this->usersCtx->getUserRank($userInfo); $colour = $this->usersCtx->getUserColour($userInfo); if($colour->shouldInherit()) { @@ -70,18 +69,23 @@ final class UsersRpcHandler implements RpcHandler { $output['colour_raw'] = $colourRaw; $output['colour_css'] = $colourCSS; - $output['rank'] = $rank; $output['country_code'] = $userInfo->countryCode; - $roles = XArray::select( - $this->usersCtx->roles->getRoles(userInfo: $userInfo, hasString: true, orderByRank: true), - fn($roleInfo) => $roleInfo->string, - ); + if($this->usersCtx->hasActiveBan($userInfo)) { + $output['rank'] = 0; + $output['roles'] = ['x-banned']; + } else { + $roles = XArray::select( + $this->usersCtx->roles->getRoles(userInfo: $userInfo, hasString: true, orderByRank: true), + fn($roleInfo) => $roleInfo->string, + ); - if(!empty($roles)) - $output['roles'] = $roles; - if($userInfo->super) - $output['is_super'] = true; + $output['rank'] = $this->usersCtx->getUserRank($userInfo); + if(!empty($roles)) + $output['roles'] = $roles; + if($userInfo->super) + $output['is_super'] = true; + } if(!empty($userInfo->title)) $output['title'] = $userInfo->title;