Skip to content

Commit 37d48c9

Browse files
authored
Merge pull request pterodactyl#3146 from xcgc/patch-1
Inform users when their server successfully installed. Fixes pterodactyl#3140
2 parents 4192bca + 397df3b commit 37d48c9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Pterodactyl\Http\Controllers\Controller;
1010
use Pterodactyl\Repositories\Eloquent\ServerRepository;
1111
use Pterodactyl\Http\Requests\Api\Remote\InstallationDataRequest;
12+
use Pterodactyl\Events\Server\Installed as ServerInstalled;
13+
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
1214

1315
class ServerInstallController extends Controller
1416
{
@@ -17,12 +19,18 @@ class ServerInstallController extends Controller
1719
*/
1820
private $repository;
1921

22+
/**
23+
* @var \Illuminate\Contracts\Events\Dispatcher
24+
*/
25+
private $eventDispatcher;
26+
2027
/**
2128
* ServerInstallController constructor.
2229
*/
23-
public function __construct(ServerRepository $repository)
30+
public function __construct(ServerRepository $repository, EventDispatcher $eventDispatcher)
2431
{
2532
$this->repository = $repository;
33+
$this->eventDispatcher = $eventDispatcher;
2634
}
2735

2836
/**
@@ -63,6 +71,11 @@ public function store(InstallationDataRequest $request, string $uuid)
6371

6472
$this->repository->update($server->id, ['status' => $status], true, true);
6573

74+
// If the server successfully installed, fire installed event.
75+
if ($status === null) {
76+
$this->eventDispatcher->dispatch(new ServerInstalled($server));
77+
}
78+
6679
return new JsonResponse([], Response::HTTP_NO_CONTENT);
6780
}
6881
}

0 commit comments

Comments
 (0)