diff --git a/src/model.rs b/src/model.rs index 2b737bc..82a3068 100644 --- a/src/model.rs +++ b/src/model.rs @@ -67,9 +67,9 @@ impl User { pub fn update(&mut self, state: crate::tcp::proto::UserState) { if state.session() != self.session { tracing::warn!("updating with different session??") } if let Some(actor) = state.actor { self.actor = actor } - if let Some(name) = state.name { if !name.is_empty() { self.name = name } } - if let Some(user_id) = state.user_id { if user_id != 0 { self.user_id = Some(user_id) } } - if let Some(comment) = state.comment { if !comment.is_empty() { self.comment = Some(comment) } } + if let Some(name) = state.name { self.name = name } + if let Some(user_id) = state.user_id { self.user_id = Some(user_id) } + if let Some(comment) = state.comment { self.comment = Some(comment) } if let Some(mute) = state.mute { self.properties.mute = mute } if let Some(deaf) = state.deaf { self.properties.deaf = deaf } if let Some(suppress) = state.suppress { self.properties.suppress = suppress } diff --git a/src/session.rs b/src/session.rs index 1a79253..0d72237 100644 --- a/src/session.rs +++ b/src/session.rs @@ -136,11 +136,11 @@ impl Session { Ok(proto::Packet::UserState(user)) => { tracing::info!("user state: {:?}", user); let mut users = session.users.write().await; - let _ = session.events.send(User::from(user.clone())); // if it fails nobody is listening match users.get_mut(&user.session()) { Some(u) => u.update(user), None => { users.insert(user.session(), User::from(user)); }, } + let _ = session.events.send(users.get(&user.session()).expect("just inserted")); // if it fails nobody is listening }, Ok(pkt) => tracing::info!("ignoring packet {:?}", pkt), }