diff --git a/crates/chattyness-user-ui/src/api/websocket.rs b/crates/chattyness-user-ui/src/api/websocket.rs index 2bb109c..108034b 100644 --- a/crates/chattyness-user-ui/src/api/websocket.rs +++ b/crates/chattyness-user-ui/src/api/websocket.rs @@ -385,7 +385,7 @@ async fn handle_socket( let _ = channel_state.tx.send(join_msg); let user_id = user.id; - let is_guest = user.is_guest(); + let mut is_guest = user.is_guest(); let tx = channel_state.tx.clone(); // Acquire a second dedicated connection for the receive task @@ -1379,7 +1379,9 @@ async fn handle_socket( // Fetch updated user info from database match users::get_user_by_id(&pool, user_id).await { Ok(Some(updated_user)) => { - let is_guest: bool = updated_user.is_guest(); + // Update the is_guest flag - critical for allowing + // newly registered users to send whispers + is_guest = updated_user.is_guest(); let display_name = updated_user.display_name.clone(); tracing::info!( @@ -1389,6 +1391,19 @@ async fn handle_socket( is_guest ); + // Update WebSocket state with the new display name + // This is critical for whispers and mod commands to find + // the user by their new name after registration + if let Some(conn) = ws_state.get_user(user_id) { + ws_state.register_user( + user_id, + conn.direct_tx.clone(), + conn.realm_id, + conn.channel_id, + display_name.clone(), + ); + } + // Broadcast identity update to all channel members let _ = tx.send(ServerMessage::MemberIdentityUpdated { user_id,