mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
Added the ability to retrieve welcome messags from APIs
This commit is contained in:
@@ -12,6 +12,7 @@ use App\Server\Exceptions\NoFreePortAvailable;
|
||||
use Illuminate\Support\Arr;
|
||||
use Ratchet\ConnectionInterface;
|
||||
use Ratchet\WebSocket\MessageComponentInterface;
|
||||
use React\EventLoop\LoopInterface;
|
||||
use React\Promise\Deferred;
|
||||
use React\Promise\PromiseInterface;
|
||||
use function React\Promise\reject;
|
||||
@@ -150,6 +151,24 @@ class ControlMessageController implements MessageComponentInterface
|
||||
});
|
||||
}
|
||||
|
||||
protected function resolveConnectionMessage($connectionInfo, $user) {
|
||||
$deferred = new Deferred();
|
||||
|
||||
$connectionMessageResolver = config('expose.admin.messages.resolve_connection_message')($connectionInfo, $user);
|
||||
|
||||
if ($connectionMessageResolver instanceof PromiseInterface) {
|
||||
$connectionMessageResolver->then(function ($connectionMessage) use ($connectionInfo, $deferred) {
|
||||
$connectionInfo->message = $connectionMessage;
|
||||
$deferred->resolve($connectionInfo);
|
||||
});
|
||||
} else {
|
||||
$connectionInfo->message = $connectionMessageResolver;
|
||||
return \React\Promise\resolve($connectionInfo);
|
||||
}
|
||||
|
||||
return $deferred->promise();
|
||||
}
|
||||
|
||||
protected function handleHttpConnection(ConnectionInterface $connection, $data, $user = null)
|
||||
{
|
||||
$this->hasValidDomain($connection, $data->server_host, $user)
|
||||
@@ -167,10 +186,13 @@ class ControlMessageController implements MessageComponentInterface
|
||||
|
||||
$this->connectionManager->limitConnectionLength($connectionInfo, config('expose.admin.maximum_connection_length'));
|
||||
|
||||
return $this->resolveConnectionMessage($connectionInfo, $user);
|
||||
})
|
||||
->then(function ($connectionInfo) use ($data, $connection, $user) {
|
||||
$connection->send(json_encode([
|
||||
'event' => 'authenticated',
|
||||
'data' => [
|
||||
'message' => config('expose.admin.messages.resolve_connection_message')($connectionInfo, $user),
|
||||
'message' => $connectionInfo->message,
|
||||
'subdomain' => $connectionInfo->subdomain,
|
||||
'server_host' => $connectionInfo->serverHost,
|
||||
'user' => $user,
|
||||
|
||||
Reference in New Issue
Block a user