mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
fix api/appservice_server events
This commit is contained in:
parent
162d01f615
commit
e49fe04f10
1 changed files with 22 additions and 19 deletions
|
|
@ -57,21 +57,19 @@ where
|
||||||
*reqwest_request.timeout_mut() = Some(Duration::from_secs(30));
|
*reqwest_request.timeout_mut() = Some(Duration::from_secs(30));
|
||||||
|
|
||||||
let url = reqwest_request.url().clone();
|
let url = reqwest_request.url().clone();
|
||||||
let mut response = match services()
|
let mut response = services()
|
||||||
.globals
|
.globals
|
||||||
.default_client()
|
.default_client()
|
||||||
.execute(reqwest_request)
|
.execute(reqwest_request)
|
||||||
.await
|
.await
|
||||||
{
|
.inspect_err(|error| {
|
||||||
Ok(r) => r,
|
|
||||||
Err(e) => {
|
|
||||||
warn!(
|
warn!(
|
||||||
"Could not send request to appservice {:?} at {}: {}",
|
%error,
|
||||||
registration.id, destination, e
|
appservice = registration.id,
|
||||||
|
%destination,
|
||||||
|
"Could not send request to appservice",
|
||||||
);
|
);
|
||||||
return Err(e.into());
|
})?;
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// reqwest::Response -> http::Response conversion
|
// reqwest::Response -> http::Response conversion
|
||||||
let status = response.status();
|
let status = response.status();
|
||||||
|
|
@ -85,18 +83,21 @@ where
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: handle timeout
|
// TODO: handle timeout
|
||||||
let body = response.bytes().await.unwrap_or_else(|e| {
|
let body = response.bytes().await.unwrap_or_else(|error| {
|
||||||
warn!("server error: {}", e);
|
warn!(%error, "Server error");
|
||||||
Vec::new().into()
|
Vec::new().into()
|
||||||
});
|
});
|
||||||
|
|
||||||
if status != 200 {
|
if status != 200 {
|
||||||
warn!(
|
warn!(
|
||||||
"Appservice returned bad response {} {}\n{}\n{:?}",
|
appservice = %destination,
|
||||||
destination,
|
%status,
|
||||||
status,
|
%url,
|
||||||
url,
|
body = %utils::dbg_truncate_str(
|
||||||
utils::string_from_bytes(&body)
|
String::from_utf8_lossy(&body).as_ref(),
|
||||||
|
100,
|
||||||
|
),
|
||||||
|
"Appservice returned bad response",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,10 +107,12 @@ where
|
||||||
.expect("reqwest body is valid http body"),
|
.expect("reqwest body is valid http body"),
|
||||||
);
|
);
|
||||||
|
|
||||||
response.map(Some).map_err(|_| {
|
response.map(Some).map_err(|error| {
|
||||||
warn!(
|
warn!(
|
||||||
"Appservice returned invalid response bytes {}\n{}",
|
%error,
|
||||||
destination, url
|
appservice = %destination,
|
||||||
|
%url,
|
||||||
|
"Appservice returned invalid response bytes",
|
||||||
);
|
);
|
||||||
Error::BadServerResponse("Server returned bad response.")
|
Error::BadServerResponse("Server returned bad response.")
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue