diff --git a/src/service/pusher/mod.rs b/src/service/pusher/mod.rs index ce469599b59cc2cc933b311d46b26f63fbe28eeb..aadc5464191e69811dc3c24bce592262a78594a6 100644 --- a/src/service/pusher/mod.rs +++ b/src/service/pusher/mod.rs @@ -60,9 +60,6 @@ pub(crate) async fn send_request<T>(&self, dest: &str, request: T) -> Result<T:: let reqwest_request = reqwest::Request::try_from(http_request)?; - // TODO: we could keep this very short and let expo backoff do it's thing... - //*reqwest_request.timeout_mut() = Some(Duration::from_secs(5)); - if let Some(url_host) = reqwest_request.url().host_str() { trace!("Checking request URL for IP"); if let Ok(ip) = IPAddress::parse(url_host) { diff --git a/src/service/sending/appservice.rs b/src/service/sending/appservice.rs index 20155c5fe56591e79f550f740f91383858b8a9ca..9a8c5f8c8c6de2a73298f1a3d5d5d1aeee02b4f8 100644 --- a/src/service/sending/appservice.rs +++ b/src/service/sending/appservice.rs @@ -1,4 +1,4 @@ -use std::{fmt::Debug, mem, time::Duration}; +use std::{fmt::Debug, mem}; use bytes::BytesMut; use ruma::api::{appservice::Registration, IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken}; @@ -25,8 +25,7 @@ pub(crate) async fn send_request<T>(registration: Registration, request: T) -> R .map_err(|e| { warn!("Failed to find destination {}: {}", destination, e); Error::BadServerResponse("Invalid destination") - }) - .unwrap() + })? .map(BytesMut::freeze); let mut parts = http_request.uri().clone().into_parts(); @@ -44,9 +43,7 @@ pub(crate) async fn send_request<T>(registration: Registration, request: T) -> R ); *http_request.uri_mut() = parts.try_into().expect("our manipulation is always valid"); - let mut reqwest_request = reqwest::Request::try_from(http_request)?; - - *reqwest_request.timeout_mut() = Some(Duration::from_secs(120)); + let reqwest_request = reqwest::Request::try_from(http_request)?; let url = reqwest_request.url().clone(); @@ -89,6 +86,8 @@ pub(crate) async fn send_request<T>(registration: Registration, request: T) -> R url, utils::string_from_bytes(&body) ); + + return Err(Error::BadServerResponse("Appservice returned unsuccessful HTTP response")); } let response = T::IncomingResponse::try_from_http_response( @@ -99,6 +98,6 @@ pub(crate) async fn send_request<T>(registration: Registration, request: T) -> R response.map(Some).map_err(|_| { warn!("Appservice returned invalid response bytes {}\n{}", destination, url); - Error::BadServerResponse("Server returned bad response.") + Error::BadServerResponse("Appservice returned bad/invalid response") }) }