Route and handle install state updates
This commit is contained in:
parent
bb9a3714cb
commit
dbc7c597d0
3 changed files with 52 additions and 2 deletions
|
@ -3,9 +3,11 @@
|
|||
namespace Pterodactyl\Http\Controllers\Api\Remote\Servers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
||||
use Pterodactyl\Http\Requests\Api\Remote\InstallationDataRequest;
|
||||
|
||||
class ServerInstallController extends Controller
|
||||
{
|
||||
|
@ -33,7 +35,7 @@ class ServerInstallController extends Controller
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function __invoke(Request $request, string $uuid)
|
||||
public function index(Request $request, string $uuid)
|
||||
{
|
||||
$server = $this->repository->getByUuid($uuid);
|
||||
$egg = $server->egg;
|
||||
|
@ -44,4 +46,25 @@ class ServerInstallController extends Controller
|
|||
'script' => $egg->copy_script_install,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the installation state of a server.
|
||||
*
|
||||
* @param \Pterodactyl\Http\Requests\Api\Remote\InstallationDataRequest $request
|
||||
* @param string $uuid
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function store(InstallationDataRequest $request, string $uuid)
|
||||
{
|
||||
$server = $this->repository->getByUuid($uuid);
|
||||
|
||||
$this->repository->update($server->id, [
|
||||
'installed' => ((bool) $request->input('successful', false)) ? 1 : 2,
|
||||
]);
|
||||
|
||||
return JsonResponse::create([], Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
|
26
app/Http/Requests/Api/Remote/InstallationDataRequest.php
Normal file
26
app/Http/Requests/Api/Remote/InstallationDataRequest.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Api\Remote;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class InstallationDataRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'successful' => 'present|boolean',
|
||||
];
|
||||
}
|
||||
}
|
|
@ -9,5 +9,6 @@ Route::post('/download-file', 'FileDownloadController@index');
|
|||
Route::post('/sftp/auth', 'SftpAuthenticationController');
|
||||
Route::group(['prefix' => '/servers/{uuid}'], function () {
|
||||
Route::get('/', 'Servers\ServerDetailsController');
|
||||
Route::get('/install', 'Servers\ServerInstallController');
|
||||
Route::get('/install', 'Servers\ServerInstallController@index');
|
||||
Route::post('/install', 'Servers\ServerInstallController@store');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue