Add ServerTransferringException, use is_null

This commit is contained in:
Matthew Penner 2020-12-17 10:34:26 -07:00
parent 5668a780e2
commit fd848985ee
9 changed files with 36 additions and 14 deletions

View file

@ -7,6 +7,7 @@ use Pterodactyl\Models\Server;
use Illuminate\Database\ConnectionInterface;
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
use Pterodactyl\Exceptions\Http\Server\ServerTransferringException;
class SuspensionService
{
@ -58,8 +59,8 @@ class SuspensionService
}
// Check if the server is currently being transferred.
if ($server->transfer !== null) {
throw new ConflictHttpException('Server is currently being transferred');
if (! is_null($server->transfer)) {
throw new ServerTransferringException();
}
$this->connection->transaction(function () use ($action, $server) {
@ -68,7 +69,7 @@ class SuspensionService
]);
// Only send the suspension request to wings if the server is not currently being transferred.
if ($server->transfer === null) {
if (is_null($server->transfer)) {
$this->daemonServerRepository->setServer($server)->suspend($action === self::ACTION_UNSUSPEND);
}
});