misc_pterodactyl-panel/app/Repositories/Wings/DaemonTransferRepository.php
2022-11-14 18:25:07 -07:00

33 lines
1.1 KiB
PHP

<?php
namespace Pterodactyl\Repositories\Wings;
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
*/
public function notify(Node $targetNode, Plain $token): void
{
try {
$this->getHttpClient()->post(sprintf('/api/servers/%s/transfer', $this->server->uuid), [
'json' => [
'server_id' => $this->server->uuid,
'url' => $targetNode->getConnectionAddress() . '/api/transfers',
'token' => 'Bearer ' . $token->toString(),
'server' => [
'uuid' => $this->server->uuid,
'start_on_completion' => false,
],
],
]);
} catch (GuzzleException $exception) {
throw new DaemonConnectionException($exception);
}
}
}