-
app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php
Open in GitHubuse Illuminate\Support\Arr; use Pterodactyl\Http\Controllers\Controller; use Illuminate\Http\Response; use Illuminate\Http\JsonResponse; class ServerTransferController extends Controller { // public function archive(Request $request, string $uuid) { $server = $this->repository->getByUuid($uuid); if (!$request->input('successful')) { return $this->processFailedTransfer($server->transfer); } $data = $this->configurationStructureService->handle($server, [ 'node_id' => $server->transfer->new_node, ]); $allocations = $server->getAllocationMappings(); $primary = array_key_first($allocations); Arr::set($data, 'allocations.default.ip', $primary); Arr::set($data, 'allocations.default.port', $allocations[$primary][0]); Arr::set($data, 'service.skip_scripts', true); Arr::set($data, 'suspended', false); $this->connection->transaction(function () use ($data, $server) { $token = $this->jwtService ->setExpiresAt(CarbonImmutable::now()->addMinutes(15)) ->setSubject($server->uuid) ->handle($server->node, $server->uuid, 'sha256'); $server->transfer->forceFill(['archived' => true])->saveOrFail(); $this->daemonTransferRepository ->setServer($server) ->setNode($server->transfer->newNode) ->notify($server, $data, $server->node, $token->toString()); }); return new JsonResponse([], Response::HTTP_NO_CONTENT); } // }