diff --git a/crates/voelin-core/src/lib.rs b/crates/voelin-core/src/lib.rs index 598e6f9..e9424f6 100644 --- a/crates/voelin-core/src/lib.rs +++ b/crates/voelin-core/src/lib.rs @@ -861,7 +861,16 @@ async fn run( }; let id = match command { Command::SetMytsIdentity(identity) => { - myts_identity.send_replace(identity); + // Still no account is no change: every notification restarts + // handshakes and sends `updatemytsid` on every connection. Any + // account is (each connection's proof is signed anew). + myts_identity.send_if_modified(|current| { + if current.is_none() && identity.is_none() { + return false; + } + *current = identity; + true + }); continue; } Command::SetAudioSettings(new) => { diff --git a/crates/voelin-core/src/versions.rs b/crates/voelin-core/src/versions.rs index c9e21fd..cdea526 100644 --- a/crates/voelin-core/src/versions.rs +++ b/crates/voelin-core/src/versions.rs @@ -108,7 +108,8 @@ fn compatibility_version(os: &str) -> Result { pub fn client_metadata() -> String { serde_json::json!({ "name": "Voelin", - "version": env!("CARGO_PKG_VERSION"), + // The app's version (it sets it at start), not this library's. + "version": voelin_platform::crash::app_version(), "platform": std::env::consts::OS, }) .to_string() @@ -151,7 +152,7 @@ mod tests { fn metadata_identifies_voelin_without_changing_signed_version() { let metadata: serde_json::Value = serde_json::from_str(&client_metadata()).unwrap(); assert_eq!(metadata["name"], "Voelin"); - assert_eq!(metadata["version"], env!("CARGO_PKG_VERSION")); + assert_eq!(metadata["version"], voelin_platform::crash::app_version()); assert_eq!(metadata["platform"], std::env::consts::OS); } diff --git a/crates/voelin-core/src/voice.rs b/crates/voelin-core/src/voice.rs index da55f6f..a4687d9 100644 --- a/crates/voelin-core/src/voice.rs +++ b/crates/voelin-core/src/voice.rs @@ -390,6 +390,10 @@ async fn run_inner( None => anyhow::bail!("connection closed"), } if identity.has_changed().unwrap_or(true) { + // Connected already: leave properly, or the server keeps a + // client with the old account until it times out, next to + // the new one. + let _ = shutdown_connection(con).await; continue; } return Ok(con); diff --git a/crates/voelin-platform/src/crash.rs b/crates/voelin-platform/src/crash.rs index ac87c8b..090c6de 100644 --- a/crates/voelin-platform/src/crash.rs +++ b/crates/voelin-platform/src/crash.rs @@ -126,6 +126,11 @@ pub fn set_app_version(version: impl Into) { config().version = version.into(); } +/// The app's version ([`set_app_version`]), also what it tells servers. +pub fn app_version() -> String { + config().version.clone() +} + /// How many reports to keep (at least one). pub fn set_keep(keep: usize) { config().keep = keep.max(1);