fix: exclude self from user list

This commit is contained in:
əlemi 2024-02-19 02:02:17 +01:00
parent 838ad5b544
commit 5cb7ca5193
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -39,6 +39,7 @@ impl Session {
}
pub async fn users(host: &str, port: Option<u16>, username: Option<String>, password: Option<String>) -> std::io::Result<Vec<crate::model::User>> {
let username = Some(username.unwrap_or_else(|| ".mumble-stats-api".to_string()));
let mut channel = ControlChannel::new(host, port).await?;
let version = proto::Version {
version_v1: None,
@ -48,7 +49,7 @@ impl Session {
os_version: None,
};
let authenticate = proto::Authenticate {
username: Some(username.unwrap_or_else(|| ".mumble-stats-api".to_string())),
username: username.clone(),
password,
tokens: Vec::new(),
celt_versions: Vec::new(),
@ -69,8 +70,12 @@ impl Session {
match channel.recv().await? {
// Ok(tcp::proto::Packet::TextMessage(msg)) => tracing::info!("{}", msg.message),
// Ok(tcp::proto::Packet::ChannelState(channel)) => tracing::info!("discovered channel: {:?}", channel.name),
proto::Packet::UserState(user) => users.push(user.into()),
proto::Packet::ServerSync(_sync) => break Ok(users),
proto::Packet::UserState(user) => {
if user.name != username {
users.push(user.into());
}
},
pkt => tracing::debug!("ignoring packet {:#?}", pkt),
}
}