Get to the point where we can start notifying the other daemon, remove TransferJob.php, add DaemonTransferRepository.php

This commit is contained in:
Matthew Penner 2020-04-04 00:50:06 -06:00
parent a2eab3ca43
commit 5007ce0b1c
8 changed files with 172 additions and 115 deletions

View file

@ -0,0 +1,31 @@
<?php
namespace Pterodactyl\Repositories\Wings;
use Pterodactyl\Models\Server;
use GuzzleHttp\Exception\TransferException;
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
class DaemonTransferRepository extends DaemonRepository
{
/**
* @param Server $server
* @param string $token
*
* @throws DaemonConnectionException
*/
public function notify(Server $server, string $token): void
{
try {
$this->getHttpClient()->post('/api/transfer', [
'json' => [
'url' => $server->node->getConnectionAddress() . sprintf('/api/servers/%s/archive', $server->uuid),
'token' => $token,
],
]);
} catch (TransferException $exception) {
throw new DaemonConnectionException($exception);
}
}
}