From 3c278a8c513dc5dd1da01e7cfda3ffb3d4ea522e Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Thu, 1 Dec 2022 11:50:28 -0700 Subject: [PATCH] api(remote): check if transfer is present before trying to update status --- .../Api/Remote/Servers/ServerTransferController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php b/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php index 72153bf25..4e8623629 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php @@ -11,6 +11,7 @@ use Illuminate\Database\ConnectionInterface; use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Repositories\Eloquent\ServerRepository; use Pterodactyl\Repositories\Wings\DaemonServerRepository; +use Symfony\Component\HttpKernel\Exception\ConflictHttpException; use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException; class ServerTransferController extends Controller @@ -33,6 +34,10 @@ class ServerTransferController extends Controller public function failure(string $uuid): JsonResponse { $server = $this->repository->getByUuid($uuid); + $transfer = $server->transfer; + if (is_null($transfer)) { + throw new ConflictHttpException('Server is not being transferred.'); + } return $this->processFailedTransfer($server->transfer); } @@ -46,6 +51,9 @@ class ServerTransferController extends Controller { $server = $this->repository->getByUuid($uuid); $transfer = $server->transfer; + if (is_null($transfer)) { + throw new ConflictHttpException('Server is not being transferred.'); + } /** @var \Pterodactyl\Models\Server $server */ $server = $this->connection->transaction(function () use ($server, $transfer) {