Fix incompatible signatures after update

This commit is contained in:
Dane Everitt 2022-02-27 10:50:25 -05:00
parent 134ba508e2
commit 764811c927
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
8 changed files with 73 additions and 17 deletions

View file

@ -2,6 +2,7 @@
namespace Pterodactyl\Http\Requests\Api\Application\Allocations; namespace Pterodactyl\Http\Requests\Api\Application\Allocations;
use Illuminate\Support\Arr;
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest; use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
class StoreAllocationRequest extends ApplicationApiRequest class StoreAllocationRequest extends ApplicationApiRequest
@ -16,14 +17,21 @@ class StoreAllocationRequest extends ApplicationApiRequest
]; ];
} }
public function validated(): array /**
* @param string|null $key
* @param string|array|null $default
* @return mixed
*/
public function validated($key = null, $default = null)
{ {
$data = parent::validated(); $data = parent::validated();
return [ $response = [
'allocation_ip' => $data['ip'], 'allocation_ip' => $data['ip'],
'allocation_ports' => $data['ports'], 'allocation_ports' => $data['ports'],
'allocation_alias' => $data['alias'] ?? null, 'allocation_alias' => $data['alias'] ?? null,
]; ];
return is_null($key) ? $response : Arr::get($response, $key, $default);
} }
} }

View file

@ -2,6 +2,7 @@
namespace Pterodactyl\Http\Requests\Api\Application\Nodes; namespace Pterodactyl\Http\Requests\Api\Application\Nodes;
use Illuminate\Support\Arr;
use Pterodactyl\Models\Node; use Pterodactyl\Models\Node;
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest; use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
@ -58,12 +59,18 @@ class StoreNodeRequest extends ApplicationApiRequest
* Change the formatting of some data keys in the validated response data * Change the formatting of some data keys in the validated response data
* to match what the application expects in the services. * to match what the application expects in the services.
* *
* @return array * @param string|null $key
* @param string|array|null $default
* @return mixed
*/ */
public function validated() public function validated($key = null, $default = null)
{ {
$response = parent::validated(); $response = parent::validated();
$response['daemon_base'] = $response['daemon_base'] ?? (new Node())->getAttribute('daemon_base'); $response['daemon_base'] = $response['daemon_base'] ?? Node::DEFAULT_DAEMON_BASE;
if (!is_null($key)) {
return Arr::get($response, $key, $default);
}
return $response; return $response;
} }

View file

@ -2,6 +2,7 @@
namespace Pterodactyl\Http\Requests\Api\Application\Servers\Databases; namespace Pterodactyl\Http\Requests\Api\Application\Servers\Databases;
use Illuminate\Support\Arr;
use Webmozart\Assert\Assert; use Webmozart\Assert\Assert;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
use Illuminate\Validation\Rule; use Illuminate\Validation\Rule;
@ -30,13 +31,20 @@ class StoreServerDatabaseRequest extends ApplicationApiRequest
]; ];
} }
public function validated(): array /**
* @param string|null $key
* @param string|array|null $default
* @return mixed
*/
public function validated($key = null, $default = null)
{ {
return [ $data = [
'database' => $this->input('database'), 'database' => $this->input('database'),
'remote' => $this->input('remote'), 'remote' => $this->input('remote'),
'database_host_id' => $this->input('host'), 'database_host_id' => $this->input('host'),
]; ];
return is_null($key) ? $data : Arr::get($data, $key, $default);
} }
public function attributes(): array public function attributes(): array

View file

@ -2,6 +2,7 @@
namespace Pterodactyl\Http\Requests\Api\Application\Servers; namespace Pterodactyl\Http\Requests\Api\Application\Servers;
use Illuminate\Support\Arr;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest; use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
@ -43,11 +44,16 @@ class StoreServerRequest extends ApplicationApiRequest
]; ];
} }
public function validated(): array /**
* @param string|null $key
* @param string|array|null $default
* @return array
*/
public function validated($key = null, $default = null)
{ {
$data = parent::validated(); $data = parent::validated();
return [ $response = [
'external_id' => array_get($data, 'external_id'), 'external_id' => array_get($data, 'external_id'),
'name' => array_get($data, 'name'), 'name' => array_get($data, 'name'),
'description' => array_get($data, 'description'), 'description' => array_get($data, 'description'),
@ -76,5 +82,7 @@ class StoreServerRequest extends ApplicationApiRequest
'skip_scripts' => array_get($data, 'skip_scripts'), 'skip_scripts' => array_get($data, 'skip_scripts'),
'start_on_completion' => array_get($data, 'start_on_completion', false), 'start_on_completion' => array_get($data, 'start_on_completion', false),
]; ];
return is_null($key) ? $response : Arr::get($response, $key, $default);
} }
} }

View file

@ -2,6 +2,7 @@
namespace Pterodactyl\Http\Requests\Api\Application\Servers; namespace Pterodactyl\Http\Requests\Api\Application\Servers;
use Illuminate\Support\Arr;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@ -52,9 +53,11 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest
/** /**
* Convert the allocation field into the expected format for the service handler. * Convert the allocation field into the expected format for the service handler.
* *
* @return array * @param string|null $key
* @param string|array|null $default
* @return mixed
*/ */
public function validated() public function validated($key = null, $default = null)
{ {
$data = parent::validated(); $data = parent::validated();
@ -73,6 +76,10 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest
unset($data['limits']); unset($data['limits']);
} }
if (!is_null($key)) {
return Arr::get($data, $key, $default);
}
return $data; return $data;
} }

View file

@ -2,6 +2,7 @@
namespace Pterodactyl\Http\Requests\Api\Application\Servers; namespace Pterodactyl\Http\Requests\Api\Application\Servers;
use Illuminate\Support\Arr;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
class UpdateServerDetailsRequest extends ServerWriteRequest class UpdateServerDetailsRequest extends ServerWriteRequest
@ -24,15 +25,20 @@ class UpdateServerDetailsRequest extends ServerWriteRequest
/** /**
* Convert the posted data into the correct format that is expected * Convert the posted data into the correct format that is expected
* by the application. * by the application.
*
* @param string|null $key
* @param string|array|null $default
*/ */
public function validated(): array public function validated($key = null, $default = null)
{ {
return [ $data = [
'external_id' => $this->input('external_id'), 'external_id' => $this->input('external_id'),
'name' => $this->input('name'), 'name' => $this->input('name'),
'owner_id' => $this->input('user'), 'owner_id' => $this->input('user'),
'description' => $this->input('description'), 'description' => $this->input('description'),
]; ];
return is_null($key) ? $data : Arr::get($data, $key, $default);
} }
/** /**

View file

@ -2,6 +2,7 @@
namespace Pterodactyl\Http\Requests\Api\Application\Servers; namespace Pterodactyl\Http\Requests\Api\Application\Servers;
use Illuminate\Support\Arr;
use Pterodactyl\Models\Server; use Pterodactyl\Models\Server;
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest; use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
@ -39,11 +40,15 @@ class UpdateServerRequest extends ApplicationApiRequest
]; ];
} }
public function validated(): array /**
* @param string|null $key
* @param string|array|null $default
* @return mixed
*/
public function validated($key = null, $default = null)
{ {
$data = parent::validated(); $data = parent::validated();
$response = [
return [
'external_id' => array_get($data, 'external_id'), 'external_id' => array_get($data, 'external_id'),
'name' => array_get($data, 'name'), 'name' => array_get($data, 'name'),
'description' => array_get($data, 'description'), 'description' => array_get($data, 'description'),
@ -65,5 +70,7 @@ class UpdateServerRequest extends ApplicationApiRequest
'add_allocations' => array_get($data, 'add_allocations'), 'add_allocations' => array_get($data, 'add_allocations'),
'remove_allocations' => array_get($data, 'remove_allocations'), 'remove_allocations' => array_get($data, 'remove_allocations'),
]; ];
return is_null($key) ? $response : Arr::get($response, $key, $default);
} }
} }

View file

@ -18,6 +18,11 @@ class Node extends Model
*/ */
public const RESOURCE_NAME = 'node'; public const RESOURCE_NAME = 'node';
/**
* The default location of server files on the Wings instance.
*/
final public const DEFAULT_DAEMON_BASE = '/var/lib/pterodactyl/volumes';
public const DAEMON_TOKEN_ID_LENGTH = 16; public const DAEMON_TOKEN_ID_LENGTH = 16;
public const DAEMON_TOKEN_LENGTH = 64; public const DAEMON_TOKEN_LENGTH = 64;
@ -104,7 +109,7 @@ class Node extends Model
'behind_proxy' => false, 'behind_proxy' => false,
'memory_overallocate' => 0, 'memory_overallocate' => 0,
'disk_overallocate' => 0, 'disk_overallocate' => 0,
'daemon_base' => '/var/lib/pterodactyl/volumes', 'daemon_base' => self::DEFAULT_DAEMON_BASE,
'maintenance_mode' => false, 'maintenance_mode' => false,
]; ];