Add configurable grid branding
This commit is contained in:
@@ -14,6 +14,11 @@ class ServerConfigSection(BaseModel):
|
||||
bind_ip: str = "127.0.0.1"
|
||||
port: int = 8765
|
||||
base_path: str = "/"
|
||||
grid_name: str = "Chat Grid"
|
||||
welcome_message: str = (
|
||||
"Welcome to the Chat Grid, your immersive audio playground. "
|
||||
"Configure your audio, then Log in or register to join the grid."
|
||||
)
|
||||
|
||||
|
||||
class NetworkConfigSection(BaseModel):
|
||||
|
||||
@@ -242,6 +242,8 @@ class AuthRequiredPacket(BasePacket):
|
||||
type: Literal["auth_required"]
|
||||
message: str
|
||||
authPolicy: dict | None = None
|
||||
gridName: str | None = None
|
||||
welcomeMessage: str | None = None
|
||||
|
||||
|
||||
class AuthResultPacket(BasePacket):
|
||||
|
||||
@@ -165,6 +165,11 @@ class SignalingServer:
|
||||
state_save_max_delay_ms: int = 1000,
|
||||
host_origin: str | None = None,
|
||||
base_path: str = "/",
|
||||
grid_name: str = "Chat Grid",
|
||||
welcome_message: str = (
|
||||
"Welcome to the Chat Grid, your immersive audio playground. "
|
||||
"Configure your audio, then Log in or register to join the grid."
|
||||
),
|
||||
):
|
||||
"""Initialize runtime state, TLS context, and item service."""
|
||||
|
||||
@@ -194,6 +199,11 @@ class SignalingServer:
|
||||
self.server_version = self._resolve_server_version()
|
||||
self.host_origin = normalize_origin(host_origin, field_name="host origin") if host_origin else None
|
||||
self.base_path = self._normalize_base_path(base_path)
|
||||
self.grid_name = str(grid_name).strip() or "Chat Grid"
|
||||
self.welcome_message = (
|
||||
str(welcome_message).strip()
|
||||
or "Welcome to the Chat Grid, your immersive audio playground. Configure your audio, then Log in or register to join the grid."
|
||||
)
|
||||
self.auth_session_cookie_name = self._session_cookie_name_for_base_path(self.base_path)
|
||||
self.websocket_path = self._base_path_join(WEBSOCKET_PATH)
|
||||
self.auth_session_cookie_set_path = self._base_path_join(AUTH_SESSION_COOKIE_SET_PATH)
|
||||
@@ -1493,6 +1503,8 @@ class SignalingServer:
|
||||
type="auth_required",
|
||||
message="Authentication required.",
|
||||
authPolicy=self._auth_policy(),
|
||||
gridName=self.grid_name,
|
||||
welcomeMessage=self.welcome_message,
|
||||
),
|
||||
)
|
||||
async for raw_message in websocket:
|
||||
@@ -1549,7 +1561,12 @@ class SignalingServer:
|
||||
"movementMaxStepsPerTick": self.movement_max_steps_per_tick,
|
||||
},
|
||||
uiDefinitions=self._build_ui_definitions(client),
|
||||
serverInfo={"instanceId": self.instance_id, "version": self.server_version},
|
||||
serverInfo={
|
||||
"instanceId": self.instance_id,
|
||||
"version": self.server_version,
|
||||
"gridName": self.grid_name,
|
||||
"welcomeMessage": self.welcome_message,
|
||||
},
|
||||
auth={
|
||||
"authenticated": client.authenticated,
|
||||
"userId": client.user_id,
|
||||
@@ -3311,5 +3328,7 @@ def run() -> None:
|
||||
state_save_max_delay_ms=config.storage.state_save_max_delay_ms,
|
||||
host_origin=host_origin,
|
||||
base_path=config.server.base_path,
|
||||
grid_name=config.server.grid_name,
|
||||
welcome_message=config.server.welcome_message,
|
||||
)
|
||||
asyncio.run(server.start())
|
||||
|
||||
@@ -5,6 +5,10 @@ bind_ip = "127.0.0.1"
|
||||
port = 8765
|
||||
# Public base path for this grid instance. Examples: "/", "/chgrid/", "/ttgrid/".
|
||||
base_path = "/"
|
||||
# User-facing grid name shown in the web client.
|
||||
grid_name = "Chat Grid"
|
||||
# User-facing pre-connect welcome text shown on the home screen.
|
||||
welcome_message = "Welcome to the Chat Grid, your immersive audio playground. Configure your audio, then Log in or register to join the grid."
|
||||
|
||||
[network]
|
||||
# Maximum inbound websocket message size in bytes.
|
||||
|
||||
@@ -59,3 +59,20 @@ base_path = "/ttgrid/"
|
||||
)
|
||||
cfg = load_config(config_path)
|
||||
assert cfg.server.base_path == "/ttgrid/"
|
||||
|
||||
|
||||
def test_load_config_reads_grid_name_and_welcome_message(tmp_path: Path) -> None:
|
||||
config_path = tmp_path / "config.toml"
|
||||
config_path.write_text(
|
||||
"""
|
||||
[network]
|
||||
allow_insecure_ws = true
|
||||
|
||||
[server]
|
||||
grid_name = "TT Grid"
|
||||
welcome_message = "Welcome to TT Grid."
|
||||
""".strip()
|
||||
)
|
||||
cfg = load_config(config_path)
|
||||
assert cfg.server.grid_name == "TT Grid"
|
||||
assert cfg.server.welcome_message == "Welcome to TT Grid."
|
||||
|
||||
Reference in New Issue
Block a user