diff options
author | Jesse Luehrs <doy@tozt.net> | 2023-07-16 16:28:48 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2023-07-16 16:29:07 -0400 |
commit | eb4669dbb7b9eb9175720ea12f2fa47f95158070 (patch) | |
tree | a8b49eec3ff7ec705a2959d3e970da42e02052cc /src/bin/rbw-agent/actions.rs | |
parent | 3e9bcc72938feee1491124ff8c5e8bec2f15bedc (diff) | |
download | rbw-eb4669dbb7b9eb9175720ea12f2fa47f95158070.tar.gz rbw-eb4669dbb7b9eb9175720ea12f2fa47f95158070.zip |
clippy and fmt
Diffstat (limited to 'src/bin/rbw-agent/actions.rs')
-rw-r--r-- | src/bin/rbw-agent/actions.rs | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/bin/rbw-agent/actions.rs b/src/bin/rbw-agent/actions.rs index 4d77133..1974736 100644 --- a/src/bin/rbw-agent/actions.rs +++ b/src/bin/rbw-agent/actions.rs @@ -1,5 +1,3 @@ -use std::f32::consts::E; - use anyhow::Context as _; pub async fn register( @@ -210,7 +208,7 @@ pub async fn login( let err = subscribe_to_notifications(state.clone()).await.err(); if let Some(e) = err { - eprintln!("failed to subscribe to notifications: {}", e) + eprintln!("failed to subscribe to notifications: {e}"); } respond_ack(sock).await?; @@ -674,7 +672,7 @@ pub async fn subscribe_to_notifications( .await .context("Config is missing")?; let email = config.email.clone().context("Config is missing email")?; - let db = rbw::db::Db::load_async(&config.server_name().as_str(), &email) + let db = rbw::db::Db::load_async(config.server_name().as_str(), &email) .await?; let access_token = db.access_token.context("Error getting access token")?; @@ -685,7 +683,7 @@ pub async fn subscribe_to_notifications( .expect("config is missing base url") .replace("https://", "wss://") + "/notifications/hub?access_token="; - websocket_url = websocket_url + &access_token; + websocket_url.push_str(&access_token); let mut state = state.write().await; let err = state @@ -694,9 +692,5 @@ pub async fn subscribe_to_notifications( .await .err(); - if let Some(err) = err { - return Err(anyhow::anyhow!(err.to_string())); - } else { - Ok(()) - } + err.map_or_else(|| Ok(()), |err| Err(anyhow::anyhow!(err.to_string()))) } |