Merge pull request #3146 from xcgc/patch-1

Inform users when their server successfully installed. Fixes #3140
This commit is contained in:
Dane Everitt 2021-03-06 10:45:23 -08:00 committed by GitHub
commit 37d48c9972
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,6 +9,8 @@ use Illuminate\Http\JsonResponse;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\Eloquent\ServerRepository;
use Pterodactyl\Http\Requests\Api\Remote\InstallationDataRequest;
use Pterodactyl\Events\Server\Installed as ServerInstalled;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
class ServerInstallController extends Controller
{
@ -17,12 +19,18 @@ class ServerInstallController extends Controller
*/
private $repository;
/**
* @var \Illuminate\Contracts\Events\Dispatcher
*/
private $eventDispatcher;
/**
* ServerInstallController constructor.
*/
public function __construct(ServerRepository $repository)
public function __construct(ServerRepository $repository, EventDispatcher $eventDispatcher)
{
$this->repository = $repository;
$this->eventDispatcher = $eventDispatcher;
}
/**
@ -63,6 +71,11 @@ class ServerInstallController extends Controller
$this->repository->update($server->id, ['status' => $status], true, true);
// If the server successfully installed, fire installed event.
if ($status === null) {
$this->eventDispatcher->dispatch(new ServerInstalled($server));
}
return new JsonResponse([], Response::HTTP_NO_CONTENT);
}
}