From 39be84fcc0f7447792c45919d3adc96d9cf1d9de Mon Sep 17 00:00:00 2001 From: flashwave Date: Thu, 21 Nov 2024 20:05:56 +0000 Subject: [PATCH] Reordered output cus it was bothering me. --- src/Users/UsersRpcHandler.php | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Users/UsersRpcHandler.php b/src/Users/UsersRpcHandler.php index 25614a2..0010f7f 100644 --- a/src/Users/UsersRpcHandler.php +++ b/src/Users/UsersRpcHandler.php @@ -53,36 +53,38 @@ final class UsersRpcHandler implements RpcHandler { $avatars = array_reverse($avatars); - $output = [ - 'id' => $userInfo->getId(), - 'name' => $userInfo->getName(), - 'colour_raw' => $colourRaw, - 'colour_css' => $colourCSS, - 'rank' => $rank, - 'country_code' => $userInfo->getCountryCode(), - 'avatar_urls' => $avatars, - 'profile_url' => $baseUrl . $this->urls->format('user-profile', ['user' => $userInfo->getId()]), - 'created_at' => $userInfo->getCreatedAt()->toIso8601ZuluString(), - ]; + $output = []; + $output['id'] = $userInfo->getId(); + $output['name'] = $userInfo->getName(); if($includeEMailAddress) $output['email'] = $userInfo->getEMailAddress(); - if($userInfo->hasLastActive()) - $output['last_active_at'] = $userInfo->getLastActiveAt()->toIso8601ZuluString(); + $output['colour_raw'] = $colourRaw; + $output['colour_css'] = $colourCSS; + $output['rank'] = $rank; + $output['country_code'] = $userInfo->getCountryCode(); $roles = XArray::select( $this->usersCtx->getRoles()->getRoles(userInfo: $userInfo, hasString: true, orderByRank: true), fn($roleInfo) => $roleInfo->getString(), ); + if(!empty($roles)) $output['roles'] = $roles; + if($userInfo->isSuperUser()) + $output['is_super'] = true; if($userInfo->hasTitle()) $output['title'] = $userInfo->getTitle(); - if($userInfo->isSuperUser()) - $output['is_super'] = true; + $output['created_at'] = $userInfo->getCreatedAt()->toIso8601ZuluString(); + if($userInfo->hasLastActive()) + $output['last_active_at'] = $userInfo->getLastActiveAt()->toIso8601ZuluString(); + + $output['profile_url'] = $baseUrl . $this->urls->format('user-profile', ['user' => $userInfo->getId()]); + $output['avatar_urls'] = $avatars; + if($userInfo->isDeleted()) $output['is_deleted'] = true;