mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
Add site details api route
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Server\Http\Controllers\Admin;
|
||||
|
||||
use App\Contracts\ConnectionManager;
|
||||
use App\Contracts\UserRepository;
|
||||
use App\Server\Configuration;
|
||||
use App\Server\Connections\ControlConnection;
|
||||
use GuzzleHttp\Psr7\Message;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\Http\Request;
|
||||
use Ratchet\ConnectionInterface;
|
||||
|
||||
class GetSiteDetailsController extends AdminController
|
||||
{
|
||||
/** @var ConnectionManager */
|
||||
protected $connectionManager;
|
||||
|
||||
/** @var Configuration */
|
||||
protected $configuration;
|
||||
|
||||
public function __construct(ConnectionManager $connectionManager, Configuration $configuration)
|
||||
{
|
||||
$this->connectionManager = $connectionManager;
|
||||
}
|
||||
|
||||
public function handle(Request $request, ConnectionInterface $httpConnection)
|
||||
{
|
||||
$domain = $request->get('site');
|
||||
|
||||
$connectedSite = collect($this->connectionManager->getConnections())
|
||||
->filter(function ($connection) {
|
||||
return get_class($connection) === ControlConnection::class;
|
||||
})
|
||||
->first(function (ControlConnection $site) use ($domain) {
|
||||
return "{$site->subdomain}.{$site->serverHost}" === $domain;
|
||||
});
|
||||
|
||||
if (is_null($connectedSite)) {
|
||||
$httpConnection->send(
|
||||
Message::toString(new Response(404))
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
$httpConnection->send(
|
||||
respond_json($connectedSite->toArray())
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -156,7 +156,7 @@ class ControlMessageController implements MessageComponentInterface
|
||||
->then(function () use ($connection, $data, $user) {
|
||||
return $this->hasValidSubdomain($connection, $data->subdomain, $user, $data->server_host);
|
||||
})
|
||||
->then(function ($subdomain) use ($data, $connection) {
|
||||
->then(function ($subdomain) use ($data, $connection, $user) {
|
||||
if ($subdomain === false) {
|
||||
return;
|
||||
}
|
||||
@@ -170,7 +170,7 @@ class ControlMessageController implements MessageComponentInterface
|
||||
$connection->send(json_encode([
|
||||
'event' => 'authenticated',
|
||||
'data' => [
|
||||
'message' => config('expose.admin.messages.message_of_the_day'),
|
||||
'message' => config('expose.admin.messages.resolve_connection_message')($connectionInfo, $user),
|
||||
'subdomain' => $connectionInfo->subdomain,
|
||||
'server_host' => $connectionInfo->serverHost,
|
||||
'client_id' => $connectionInfo->client_id,
|
||||
|
||||
Reference in New Issue
Block a user