Merge pull request #3146 from xcgc/patch-1
Inform users when their server successfully installed. Fixes #3140
This commit is contained in:
commit
37d48c9972
1 changed files with 14 additions and 1 deletions
|
@ -9,6 +9,8 @@ use Illuminate\Http\JsonResponse;
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
||||||
use Pterodactyl\Http\Requests\Api\Remote\InstallationDataRequest;
|
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
|
class ServerInstallController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -17,12 +19,18 @@ class ServerInstallController extends Controller
|
||||||
*/
|
*/
|
||||||
private $repository;
|
private $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Illuminate\Contracts\Events\Dispatcher
|
||||||
|
*/
|
||||||
|
private $eventDispatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ServerInstallController constructor.
|
* ServerInstallController constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(ServerRepository $repository)
|
public function __construct(ServerRepository $repository, EventDispatcher $eventDispatcher)
|
||||||
{
|
{
|
||||||
$this->repository = $repository;
|
$this->repository = $repository;
|
||||||
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,6 +71,11 @@ class ServerInstallController extends Controller
|
||||||
|
|
||||||
$this->repository->update($server->id, ['status' => $status], true, true);
|
$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);
|
return new JsonResponse([], Response::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue