diff --git a/CHANGELOG.md b/CHANGELOG.md index 52d63e614..52388083a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,9 @@ error encountered during creation or update. ### Added * Server listing view now displays the total used disk space for each server. +* Client API endpoint to list all servers now supports an additional `?filter=subuser-of|all|admin|owner` parameter to +return different groupings of servers. The default value is `subuser-of` which will include all of the user's servers +that they are the owner of, as well as all servers they're a subuser of. ### Changed * Updated Paper egg to not download `server.properties` each time. [parkervcp/eggs#260](https://github.com/parkervcp/eggs/issues/260) diff --git a/app/Http/Controllers/Api/Client/ClientController.php b/app/Http/Controllers/Api/Client/ClientController.php index 2dffba8f0..7b8f4b23d 100644 --- a/app/Http/Controllers/Api/Client/ClientController.php +++ b/app/Http/Controllers/Api/Client/ClientController.php @@ -35,7 +35,26 @@ class ClientController extends ClientApiController */ public function index(GetServersRequest $request): array { - $servers = $this->repository->filterUserAccessServers($request->user(), User::FILTER_LEVEL_SUBUSER, config('pterodactyl.paginate.frontend.servers')); + // Check for the filter parameter on the request. + switch ($request->input('filter')) { + case 'all': + $filter = User::FILTER_LEVEL_ALL; + break; + case 'admin': + $filter = User::FILTER_LEVEL_ADMIN; + break; + case 'owner': + $filter = User::FILTER_LEVEL_OWNER; + break; + case 'subuser-of': + default: + $filter = User::FILTER_LEVEL_SUBUSER; + break; + } + + $servers = $this->repository->filterUserAccessServers( + $request->user(), $filter, config('pterodactyl.paginate.frontend.servers') + ); return $this->fractal->collection($servers) ->transformWith($this->getTransformer(ServerTransformer::class))