Skip to content

Commit fe9d86b

Browse files
committed
Add support for filtering servers in client list-all endpoint
closes pterodactyl#1608
1 parent 47c1292 commit fe9d86b

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ error encountered during creation or update.
1616

1717
### Added
1818
* Server listing view now displays the total used disk space for each server.
19+
* Client API endpoint to list all servers now supports an additional `?filter=subuser-of|all|admin|owner` parameter to
20+
return different groupings of servers. The default value is `subuser-of` which will include all of the user's servers
21+
that they are the owner of, as well as all servers they're a subuser of.
1922

2023
### Changed
2124
* Updated Paper egg to not download `server.properties` each time. [parkervcp/eggs#260](https://github.com/parkervcp/eggs/issues/260)

app/Http/Controllers/Api/Client/ClientController.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,26 @@ public function __construct(ServerRepositoryInterface $repository)
3535
*/
3636
public function index(GetServersRequest $request): array
3737
{
38-
$servers = $this->repository->filterUserAccessServers($request->user(), User::FILTER_LEVEL_SUBUSER, config('pterodactyl.paginate.frontend.servers'));
38+
// Check for the filter parameter on the request.
39+
switch ($request->input('filter')) {
40+
case 'all':
41+
$filter = User::FILTER_LEVEL_ALL;
42+
break;
43+
case 'admin':
44+
$filter = User::FILTER_LEVEL_ADMIN;
45+
break;
46+
case 'owner':
47+
$filter = User::FILTER_LEVEL_OWNER;
48+
break;
49+
case 'subuser-of':
50+
default:
51+
$filter = User::FILTER_LEVEL_SUBUSER;
52+
break;
53+
}
54+
55+
$servers = $this->repository->filterUserAccessServers(
56+
$request->user(), $filter, config('pterodactyl.paginate.frontend.servers')
57+
);
3958

4059
return $this->fractal->collection($servers)
4160
->transformWith($this->getTransformer(ServerTransformer::class))

0 commit comments

Comments
 (0)