Remove unnecessary API calls to daemon

This commit is contained in:
Dane Everitt 2019-12-22 13:45:40 -08:00
parent 59bfc212c9
commit 34ffcdae7a
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
10 changed files with 10 additions and 312 deletions

View file

@ -18,7 +18,6 @@ use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\Servers\SuspensionService;
use Pterodactyl\Services\Servers\ServerDeletionService;
use Pterodactyl\Services\Servers\ReinstallServerService;
use Pterodactyl\Services\Servers\ContainerRebuildService;
use Pterodactyl\Services\Servers\BuildModificationService;
use Pterodactyl\Services\Databases\DatabasePasswordService;
use Pterodactyl\Services\Servers\DetailsModificationService;
@ -54,11 +53,6 @@ class ServersController extends Controller
*/
protected $config;
/**
* @var \Pterodactyl\Services\Servers\ContainerRebuildService
*/
protected $containerRebuildService;
/**
* @var \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface
*/
@ -121,7 +115,6 @@ class ServersController extends Controller
* @param \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface $allocationRepository
* @param \Pterodactyl\Services\Servers\BuildModificationService $buildModificationService
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Pterodactyl\Services\Servers\ContainerRebuildService $containerRebuildService
* @param \Pterodactyl\Services\Databases\DatabaseManagementService $databaseManagementService
* @param \Pterodactyl\Services\Databases\DatabasePasswordService $databasePasswordService
* @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $databaseRepository
@ -139,7 +132,6 @@ class ServersController extends Controller
AllocationRepositoryInterface $allocationRepository,
BuildModificationService $buildModificationService,
ConfigRepository $config,
ContainerRebuildService $containerRebuildService,
DatabaseManagementService $databaseManagementService,
DatabasePasswordService $databasePasswordService,
DatabaseRepositoryInterface $databaseRepository,
@ -156,7 +148,6 @@ class ServersController extends Controller
$this->allocationRepository = $allocationRepository;
$this->buildModificationService = $buildModificationService;
$this->config = $config;
$this->containerRebuildService = $containerRebuildService;
$this->databaseHostRepository = $databaseHostRepository;
$this->databaseManagementService = $databaseManagementService;
$this->databasePasswordService = $databasePasswordService;
@ -235,21 +226,6 @@ class ServersController extends Controller
return redirect()->route('admin.servers.view.manage', $server->id);
}
/**
* Setup a server to have a container rebuild.
*
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function rebuildContainer(Server $server)
{
$this->containerRebuildService->handle($server);
$this->alert->success(trans('admin/server.alerts.rebuild_on_boot'))->flash();
return redirect()->route('admin.servers.view.manage', $server->id);
}
/**
* Manage the suspension status for a server.
*
@ -302,7 +278,7 @@ class ServersController extends Controller
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Throwable
*/
public function delete(Request $request, Server $server)
{
@ -320,7 +296,6 @@ class ServersController extends Controller
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Illuminate\Validation\ValidationException
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/

View file

@ -63,15 +63,16 @@ class ServerDetailsController extends ApplicationApiController
* Update the build details for a specific server.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerBuildConfigurationRequest $request
* @param \Pterodactyl\Models\Server $server
* @return array
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function build(UpdateServerBuildConfigurationRequest $request): array
public function build(UpdateServerBuildConfigurationRequest $request, Server $server): array
{
$server = $this->buildModificationService->handle($request->getModel(Server::class), $request->validated());
$server = $this->buildModificationService->handle($server, $request->validated());
return $this->fractal->item($server)
->transformWith($this->getTransformer(ServerTransformer::class))

View file

@ -6,17 +6,11 @@ use Illuminate\Http\Response;
use Pterodactyl\Models\Server;
use Pterodactyl\Services\Servers\SuspensionService;
use Pterodactyl\Services\Servers\ReinstallServerService;
use Pterodactyl\Services\Servers\ContainerRebuildService;
use Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest;
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
class ServerManagementController extends ApplicationApiController
{
/**
* @var \Pterodactyl\Services\Servers\ContainerRebuildService
*/
private $rebuildService;
/**
* @var \Pterodactyl\Services\Servers\ReinstallServerService
*/
@ -30,18 +24,15 @@ class ServerManagementController extends ApplicationApiController
/**
* SuspensionController constructor.
*
* @param \Pterodactyl\Services\Servers\ContainerRebuildService $rebuildService
* @param \Pterodactyl\Services\Servers\ReinstallServerService $reinstallServerService
* @param \Pterodactyl\Services\Servers\SuspensionService $suspensionService
*/
public function __construct(
ContainerRebuildService $rebuildService,
ReinstallServerService $reinstallServerService,
SuspensionService $suspensionService
) {
parent::__construct();
$this->rebuildService = $rebuildService;
$this->reinstallServerService = $reinstallServerService;
$this->suspensionService = $suspensionService;
}
@ -53,9 +44,7 @@ class ServerManagementController extends ApplicationApiController
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\Response
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Throwable
*/
public function suspend(ServerWriteRequest $request, Server $server): Response
{
@ -71,9 +60,7 @@ class ServerManagementController extends ApplicationApiController
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\Response
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Throwable
*/
public function unsuspend(ServerWriteRequest $request, Server $server): Response
{
@ -99,20 +86,4 @@ class ServerManagementController extends ApplicationApiController
return $this->returnNoContent();
}
/**
* Mark a server as needing its container rebuilt the next time it is started.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\Response
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function rebuild(ServerWriteRequest $request, Server $server): Response
{
$this->rebuildService->handle($server);
return $this->returnNoContent();
}
}