fix: feature gate some guest features in the backend

This commit is contained in:
Evan Carroll 2026-01-19 01:03:46 -06:00
parent 39750c1d82
commit 226c2e02b5
3 changed files with 33 additions and 0 deletions

View file

@ -353,6 +353,7 @@ async fn handle_socket(
let _ = channel_state.tx.send(join_msg);
let user_id = user.id;
let is_guest = user.is_guest();
let tx = channel_state.tx.clone();
// Acquire a second dedicated connection for the receive task
@ -509,6 +510,17 @@ async fn handle_socket(
// Handle whisper (direct message) vs broadcast
if let Some(target_name) = target_display_name {
// Check if guest is trying to whisper
if is_guest {
let _ = direct_tx
.send(ServerMessage::Error {
code: "GUEST_FEATURE_DISABLED".to_string(),
message: "Private messaging is disabled for guests, please register first.".to_string(),
})
.await;
continue;
}
// Whisper: send directly to target user
if let Some((_target_user_id, target_conn)) = ws_state
.find_user_by_display_name(realm_id, &target_name)