diff --git a/server-cli/src/cli.rs b/server-cli/src/cli.rs index 652d9b9c6e..1a88e8df00 100644 --- a/server-cli/src/cli.rs +++ b/server-cli/src/cli.rs @@ -74,7 +74,8 @@ pub enum Message { /// returns active player names ListPlayers, ListLogs, - SendWorldMsg { + /// sends a msg to everyone on the server + SendGlobalMsg { msg: String, }, } diff --git a/server-cli/src/main.rs b/server-cli/src/main.rs index 3549c7bdd2..77c680ebd5 100644 --- a/server-cli/src/main.rs +++ b/server-cli/src/main.rs @@ -398,7 +398,7 @@ fn server_loop( .collect(); let _ = response.send(MessageReturn::Logs(lines)); }, - Message::SendWorldMsg { msg } => { + Message::SendGlobalMsg { msg } => { use server::state_ext::StateExt; let msg = ChatType::Meta.into_plain_msg(msg); server.state().send_chat(msg); diff --git a/server-cli/src/settings.rs b/server-cli/src/settings.rs index 010b3b1c49..412b924305 100644 --- a/server-cli/src/settings.rs +++ b/server-cli/src/settings.rs @@ -34,8 +34,8 @@ pub struct Settings { /// SECRET API HEADER used to access the chat api, if disabled the API is /// unreachable pub web_chat_secret: Option, - /// public SECRET API HEADER used to access the ui api, if disabled the API - /// is reachable localhost only + /// public SECRET API HEADER used to access the /ui_api, if disabled the API + /// is reachable localhost only (by /ui) pub ui_api_secret: Option, pub shutdown_signals: Vec, } diff --git a/server-cli/src/web/ui/api.rs b/server-cli/src/web/ui/api.rs index 28baeb5f6d..0e6949e5c7 100644 --- a/server-cli/src/web/ui/api.rs +++ b/server-cli/src/web/ui/api.rs @@ -70,7 +70,7 @@ pub fn router(web_ui_request_s: UiRequestSender, secret_token: String) -> Router Router::new() .route("/players", get(players)) .route("/logs", get(logs)) - .route("/send_world_msg", post(send_world_msg)) + .route("/send_global_msg", post(send_global_msg)) .layer(axum::middleware::from_fn_with_state(ip_addrs, log_users)) .layer(axum::middleware::from_fn_with_state(token, validate_secret)) .with_state(web_ui_request_s) @@ -109,13 +109,13 @@ struct SendWorldMsgBody { msg: String, } -async fn send_world_msg( +async fn send_global_msg( State(web_ui_request_s): State, Json(payload): Json, ) -> Result { let (dummy_s, _) = tokio::sync::oneshot::channel(); let _ = web_ui_request_s - .send((Message::SendWorldMsg { msg: payload.msg }, dummy_s)) + .send((Message::SendGlobalMsg { msg: payload.msg }, dummy_s)) .await; Ok(()) } diff --git a/server-cli/src/web/ui/mod.rs b/server-cli/src/web/ui/mod.rs index e93e9cbb76..a1e8790f43 100644 --- a/server-cli/src/web/ui/mod.rs +++ b/server-cli/src/web/ui/mod.rs @@ -29,7 +29,7 @@ async fn ui( r#" -Ui is only accissable from 127.0.0.1 +Ui is only accessible from 127.0.0.1 "# diff --git a/server-cli/src/web/ui/ui.js b/server-cli/src/web/ui/ui.js index 263f3d83dd..fb650f48db 100644 --- a/server-cli/src/web/ui/ui.js +++ b/server-cli/src/web/ui/ui.js @@ -29,7 +29,7 @@ async function sendGlobalMsg() { var world_msg = document.getElementById("world_msg"); const msg_text = world_msg.value; - const msg_response = await fetch("/ui_api/v1/send_world_msg", { + const msg_response = await fetch("/ui_api/v1/send_global_msg", { method: "POST", headers: { "Content-Type": "application/json",