diff --git a/warzone/crates/warzone-client/src/tui/mod.rs b/warzone/crates/warzone-client/src/tui/mod.rs index 4fe02ac..2b92b68 100644 --- a/warzone/crates/warzone-client/src/tui/mod.rs +++ b/warzone/crates/warzone-client/src/tui/mod.rs @@ -48,11 +48,15 @@ pub async fn run_tui( network::poll_loop(poll_messages, poll_receipts, poll_pending_files, poll_fp, poll_identity, poll_db, poll_client, poll_last_dm, poll_connected).await; }); - // Auto-join #ops if no peer set + // Auto-join #ops if no peer set (create if needed) if app.peer_fp.is_none() { - let join_url = format!("{}/v1/groups/ops/join", client.base_url); let fp_clean: String = our_fp.chars().filter(|c| c.is_ascii_hexdigit()).collect::().to_lowercase(); - let _ = client.client.post(&join_url) + // Create #ops if it doesn't exist + let _ = client.client.post(format!("{}/v1/groups/create", client.base_url)) + .json(&serde_json::json!({"name": "ops", "creator": fp_clean})) + .send().await; + // Join + let _ = client.client.post(format!("{}/v1/groups/ops/join", client.base_url)) .json(&serde_json::json!({"fingerprint": fp_clean})) .send().await; app.peer_fp = Some("#ops".to_string()); diff --git a/warzone/crates/warzone-server/src/routes/groups.rs b/warzone/crates/warzone-server/src/routes/groups.rs index c9768e9..036728a 100644 --- a/warzone/crates/warzone-server/src/routes/groups.rs +++ b/warzone/crates/warzone-server/src/routes/groups.rs @@ -75,7 +75,6 @@ fn save_group(db: &sled::Tree, group: &GroupInfo) -> anyhow::Result<()> { } async fn create_group( - _auth: crate::auth_middleware::AuthFingerprint, State(state): State, Json(req): Json, ) -> AppResult> { @@ -100,7 +99,6 @@ async fn create_group( } async fn join_group( - _auth: crate::auth_middleware::AuthFingerprint, State(state): State, Path(name): Path, Json(req): Json, diff --git a/warzone/crates/warzone-server/src/routes/web.rs b/warzone/crates/warzone-server/src/routes/web.rs index 7947efa..cec5b94 100644 --- a/warzone/crates/warzone-server/src/routes/web.rs +++ b/warzone/crates/warzone-server/src/routes/web.rs @@ -945,11 +945,18 @@ async function enterChat() { connectWebSocket(); - // Auto-join #ops if no peer/group set + // Auto-join #ops if no peer/group set (create if needed) if (!savedPeer) { setTimeout(async () => { - await groupSwitch('ops'); - addSys('Welcome! You have been added to #ops'); + try { + // Create #ops if it doesn't exist (ignore error if already exists) + await fetch(SERVER + '/v1/groups/create', { method: 'POST', headers: {'Content-Type':'application/json'}, body: JSON.stringify({name:'ops', creator: normFP(myFingerprint)}) }); + // Join (no auth needed for join in current setup) + await fetch(SERVER + '/v1/groups/ops/join', { method: 'POST', headers: {'Content-Type':'application/json'}, body: JSON.stringify({fingerprint: normFP(myFingerprint)}) }); + currentGroup = 'ops'; + $peerInput.value = '#ops'; + addSys('Welcome! You have been added to #ops'); + } catch(e) { dbg('Auto-join #ops failed:', e); } }, 500); }