From bd4d123223617741f35025f752784cdcb53c88b2 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 27 Mar 2024 04:38:14 +0100 Subject: [PATCH] fix: less extreme logging for deliveries --- src/dispatcher.rs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/dispatcher.rs b/src/dispatcher.rs index 53d5f5cc..0b10414b 100644 --- a/src/dispatcher.rs +++ b/src/dispatcher.rs @@ -98,8 +98,6 @@ async fn deliver(key: &PKey, to: &str, from: &str, payload: serde_json: let date = chrono::Utc::now().format("%a, %d %b %Y %H:%M:%S GMT").to_string(); // lmao @ "GMT" let path = to.replace("https://", "").replace("http://", "").replace(&host, ""); - tracing::info!("payload:\n{payload}\n{digest}"); - // let headers : BTreeMap = [ // ("Host".to_string(), host.clone()), // ("Date".to_string(), date.clone()), @@ -125,16 +123,13 @@ async fn deliver(key: &PKey, to: &str, from: &str, payload: serde_json: let signature_header = { let to_sign = format!("(request-target): post {path}\nhost: {host}\ndate: {date}\ndigest: {digest}"); - tracing::info!("signing:\n{to_sign}"); let mut signer = Signer::new(MessageDigest::sha256(), key)?; signer.update(to_sign.as_bytes())?; let signature = base64::prelude::BASE64_STANDARD.encode(signer.sign_to_vec()?); format!("keyId=\"{from}#main-key\",algorithm=\"rsa-sha256\",headers=\"(request-target) host date digest\",signature=\"{signature}\"") }; - tracing::info!("signature header:\n{signature_header}"); - - let res = reqwest::Client::new() + reqwest::Client::new() .post(to) .header("Host", host) .header("Date", date) @@ -144,15 +139,9 @@ async fn deliver(key: &PKey, to: &str, from: &str, payload: serde_json: .header(USER_AGENT, format!("upub+{VERSION} ({domain})")) // TODO put instance admin email .body(payload) .send() - .await?; + .await? + .error_for_status()?; - let status = res.status(); - let txt = res.text().await?; - tracing::info!("delivery answer: {txt}"); - if status.is_client_error() || status.is_server_error() { - Err(UpubError::Status(axum::http::StatusCode::from_u16(status.as_u16()).unwrap())) - } else { - Ok(()) - } + Ok(()) }