2020-04-04 06:50:06 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Repositories\Wings;
|
|
|
|
|
2020-04-04 20:10:18 +00:00
|
|
|
use Pterodactyl\Models\Node;
|
2020-04-04 06:50:06 +00:00
|
|
|
use Pterodactyl\Models\Server;
|
|
|
|
use GuzzleHttp\Exception\TransferException;
|
|
|
|
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
|
|
|
|
|
|
|
class DaemonTransferRepository extends DaemonRepository
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @throws DaemonConnectionException
|
|
|
|
*/
|
2020-04-04 22:24:58 +00:00
|
|
|
public function notify(Server $server, array $data, Node $node, string $token): void
|
|
|
|
{
|
2020-04-04 06:50:06 +00:00
|
|
|
try {
|
|
|
|
$this->getHttpClient()->post('/api/transfer', [
|
|
|
|
'json' => [
|
2020-04-04 20:10:18 +00:00
|
|
|
'server_id' => $server->uuid,
|
|
|
|
'url' => $node->getConnectionAddress() . sprintf('/api/servers/%s/archive', $server->uuid),
|
|
|
|
'token' => 'Bearer ' . $token,
|
2020-04-04 22:16:18 +00:00
|
|
|
'server' => $data,
|
2020-04-04 06:50:06 +00:00
|
|
|
],
|
|
|
|
]);
|
2020-04-04 22:24:58 +00:00
|
|
|
} catch (TransferException $exception) {
|
2020-04-04 06:50:06 +00:00
|
|
|
throw new DaemonConnectionException($exception);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|