misc_pterodactyl-panel/app/Repositories/Wings/DaemonTransferRepository.php

34 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace Pterodactyl\Repositories\Wings;
2022-11-15 01:25:07 +00:00
use Pterodactyl\Models\Node;
use Lcobucci\JWT\Token\Plain;
use GuzzleHttp\Exception\GuzzleException;
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
class DaemonTransferRepository extends DaemonRepository
{
/**
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
2022-11-15 01:25:07 +00:00
public function notify(Node $targetNode, Plain $token): void
2020-04-04 22:24:58 +00:00
{
try {
2022-11-15 01:25:07 +00:00
$this->getHttpClient()->post(sprintf('/api/servers/%s/transfer', $this->server->uuid), [
'json' => [
2022-11-15 01:25:07 +00:00
'server_id' => $this->server->uuid,
'url' => $targetNode->getConnectionAddress() . '/api/transfers',
'token' => 'Bearer ' . $token->toString(),
'server' => [
2022-11-15 01:25:07 +00:00
'uuid' => $this->server->uuid,
'start_on_completion' => false,
],
],
]);
} catch (GuzzleException $exception) {
throw new DaemonConnectionException($exception);
}
}
}