API model updates, as well as general model updates and code fixes.
This commit is contained in:
parent
8dc1f41b73
commit
32a1dc17ed
16 changed files with 162 additions and 272 deletions
|
@ -32,19 +32,16 @@ class InfoController extends BaseController
|
|||
{
|
||||
public function me(Request $request)
|
||||
{
|
||||
return $request->user()->serverAccessCollection()->map(function ($server) {
|
||||
return $request->user()->serverAccessCollection()->load('allocation', 'option')->map(function ($server) {
|
||||
return [
|
||||
'id' => $server->uuidShort,
|
||||
'uuid' => $server->uuid,
|
||||
'name' => $server->name,
|
||||
'node' => $server->node_idName,
|
||||
'ip' => [
|
||||
'set' => $server->ip,
|
||||
'alias' => $server->ip_alias,
|
||||
],
|
||||
'port' => $server->port,
|
||||
'service' => $server->a_serviceName,
|
||||
'option' => $server->a_serviceOptionName,
|
||||
'node' => $server->node->name,
|
||||
'ip' => $server->allocation->alias,
|
||||
'port' => $server->allocation->port,
|
||||
'service' => $server->service->name,
|
||||
'option' => $server->option->name,
|
||||
];
|
||||
})->all();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
namespace Pterodactyl\Http\Controllers\API\User;
|
||||
|
||||
use Log;
|
||||
use Auth;
|
||||
use Pterodactyl\Models;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Http\Controllers\API\BaseController;
|
||||
|
@ -43,20 +42,14 @@ class ServerController extends BaseController
|
|||
$daemon = [
|
||||
'status' => $json->status,
|
||||
'stats' => $json->proc,
|
||||
'query' => $json->query,
|
||||
];
|
||||
} catch (\Exception $ex) {
|
||||
$daemon = [
|
||||
'error' => 'An error was encountered while trying to connect to the daemon to collece information. It might be offline.',
|
||||
'error' => 'An error was encountered while trying to connect to the daemon to collect information. It might be offline.',
|
||||
];
|
||||
Log::error($ex);
|
||||
}
|
||||
|
||||
foreach ($server->allocations as &$allocation) {
|
||||
$allocation->default = ($allocation->id === $server->allocation_id);
|
||||
unset($allocation->id);
|
||||
}
|
||||
|
||||
return [
|
||||
'uuidShort' => $server->uuidShort,
|
||||
'uuid' => $server->uuid,
|
||||
|
@ -70,12 +63,18 @@ class ServerController extends BaseController
|
|||
'cpu' => $server->cpu,
|
||||
'oom_disabled' => (bool) $server->oom_disabled,
|
||||
],
|
||||
'allocations' => $server->allocations,
|
||||
'allocations' => $server->allocations->map(function ($item) use ($server) {
|
||||
return [
|
||||
'ip' => $item->alias,
|
||||
'port' => $item->port,
|
||||
'default' => ($item->id === $server->allocation_id),
|
||||
];
|
||||
}),
|
||||
'sftp' => [
|
||||
'username' => (Auth::user()->can('view-sftp', $server)) ? $server->username : null,
|
||||
'username' => ($request->user()->can('view-sftp', $server)) ? $server->username : null,
|
||||
],
|
||||
'daemon' => [
|
||||
'token' => ($request->secure()) ? $server->daemonSecret : false,
|
||||
'token' => $server->daemonSecret,
|
||||
'response' => $daemon,
|
||||
],
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue