1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-22 00:52:43 +01:00

api(remote): check if transfer is present before trying to update status

This commit is contained in:
Matthew Penner 2022-12-01 11:50:28 -07:00
parent 794248d4d7
commit 3c278a8c51
No known key found for this signature in database

View File

@ -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) {