Skip to content

Commit 2d47f98

Browse files
committed
Replace calls to server patch with a manual sync method
1 parent d8d1eac commit 2d47f98

File tree

3 files changed

+8
-29
lines changed

3 files changed

+8
-29
lines changed

app/Repositories/Wings/DaemonServerRepository.php

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Webmozart\Assert\Assert;
66
use Pterodactyl\Models\Server;
7+
use GuzzleHttp\Exception\GuzzleException;
78
use GuzzleHttp\Exception\TransferException;
89
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
910

@@ -51,17 +52,17 @@ public function create(array $data): void
5152
}
5253

5354
/**
54-
* Updates details about a server on the Daemon.
55+
* Triggers a server sync on Wings.
5556
*
5657
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
5758
*/
58-
public function update(array $data): void
59+
public function sync(): void
5960
{
6061
Assert::isInstanceOf($this->server, Server::class);
6162

6263
try {
63-
$this->getHttpClient()->patch('/api/servers/' . $this->server->uuid, ['json' => $data]);
64-
} catch (TransferException $exception) {
64+
$this->getHttpClient()->post("/api/servers/{$this->server->uuid}/sync");
65+
} catch (GuzzleException $exception) {
6566
throw new DaemonConnectionException($exception);
6667
}
6768
}
@@ -101,26 +102,6 @@ public function reinstall(): void
101102
}
102103
}
103104

104-
/**
105-
* By default this function will suspend a server instance on the daemon. However, passing
106-
* "true" as the first argument will unsuspend the server.
107-
*
108-
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
109-
*/
110-
public function suspend(bool $unsuspend = false): void
111-
{
112-
Assert::isInstanceOf($this->server, Server::class);
113-
114-
try {
115-
$this->getHttpClient()->patch(
116-
'/api/servers/' . $this->server->uuid,
117-
['json' => ['suspended' => !$unsuspend]]
118-
);
119-
} catch (TransferException $exception) {
120-
throw new DaemonConnectionException($exception);
121-
}
122-
}
123-
124105
/**
125106
* Requests the daemon to create a full archive of the server. Once the daemon is finished
126107
* they will send a POST request to "/api/remote/servers/{uuid}/archive" with a boolean.

app/Services/Servers/BuildModificationService.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ public function handle(Server $server, array $data)
9191
// if it fails we can just continue on as normal.
9292
if (!empty($updateData['build'])) {
9393
try {
94-
$this->daemonServerRepository->setServer($server)->update([
95-
'build' => $updateData['build'],
96-
]);
94+
$this->daemonServerRepository->setServer($server)->sync();
9795
} catch (DaemonConnectionException $exception) {
9896
Log::warning($exception, ['server_id' => $server->id]);
9997
}

app/Services/Servers/SuspensionService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ public function toggle(Server $server, $action = self::ACTION_SUSPEND)
6363
'status' => $isSuspending ? Server::STATUS_SUSPENDED : null,
6464
]);
6565

66-
// Only send the suspension request to wings if the server is not currently being transferred.
66+
// Only trigger a Wings server sync if it is not currently being transferred.
6767
if (is_null($server->transfer)) {
68-
$this->daemonServerRepository->setServer($server)->suspend($action === self::ACTION_UNSUSPEND);
68+
$this->daemonServerRepository->setServer($server)->sync();
6969
}
7070
});
7171
}

0 commit comments

Comments
 (0)