fix: auto-join #ops creates group if missing, remove auth from create/join group

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-03-29 14:47:54 +04:00
parent 13f2227bf0
commit 5415d1f5c8
3 changed files with 17 additions and 8 deletions

View File

@@ -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<AppState>,
Json(req): Json<CreateRequest>,
) -> AppResult<Json<serde_json::Value>> {
@@ -100,7 +99,6 @@ async fn create_group(
}
async fn join_group(
_auth: crate::auth_middleware::AuthFingerprint,
State(state): State<AppState>,
Path(name): Path<String>,
Json(req): Json<JoinRequest>,

View File

@@ -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);
}