This commit is contained in:
Jonas Platte 2021-04-29 20:50:09 +02:00
parent 54a0f21347
commit 42a7a9f795
No known key found for this signature in database
GPG key ID: CC154DE0E30B7C67
3 changed files with 47 additions and 41 deletions

39
Cargo.lock generated
View file

@ -1655,7 +1655,7 @@ dependencies = [
[[package]]
name = "ruma"
version = "0.0.3"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"assign",
"js_int",
@ -1676,7 +1676,7 @@ dependencies = [
[[package]]
name = "ruma-api"
version = "0.17.0-alpha.4"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"bytes",
"http",
@ -1692,7 +1692,7 @@ dependencies = [
[[package]]
name = "ruma-api-macros"
version = "0.17.0-alpha.4"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"proc-macro-crate",
"proc-macro2",
@ -1703,7 +1703,7 @@ dependencies = [
[[package]]
name = "ruma-appservice-api"
version = "0.2.0-alpha.3"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"ruma-api",
"ruma-common",
@ -1717,7 +1717,7 @@ dependencies = [
[[package]]
name = "ruma-client"
version = "0.5.0-alpha.2"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"assign",
"async-stream",
@ -1725,6 +1725,7 @@ dependencies = [
"bytes",
"futures-core",
"http",
"reqwest",
"ruma-api",
"ruma-common",
"ruma-events",
@ -1737,7 +1738,7 @@ dependencies = [
[[package]]
name = "ruma-client-api"
version = "0.10.0-alpha.3"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"assign",
"bytes",
@ -1757,7 +1758,7 @@ dependencies = [
[[package]]
name = "ruma-common"
version = "0.5.0"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"indexmap",
"js_int",
@ -1773,7 +1774,7 @@ dependencies = [
[[package]]
name = "ruma-events"
version = "0.22.0-alpha.3"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"js_int",
"ruma-common",
@ -1787,7 +1788,7 @@ dependencies = [
[[package]]
name = "ruma-events-macros"
version = "0.22.0-alpha.3"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"proc-macro-crate",
"proc-macro2",
@ -1798,7 +1799,7 @@ dependencies = [
[[package]]
name = "ruma-federation-api"
version = "0.1.0-alpha.2"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"js_int",
"ruma-api",
@ -1813,7 +1814,7 @@ dependencies = [
[[package]]
name = "ruma-identifiers"
version = "0.19.0"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"paste",
"rand",
@ -1827,7 +1828,7 @@ dependencies = [
[[package]]
name = "ruma-identifiers-macros"
version = "0.19.0"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"proc-macro2",
"quote",
@ -1838,12 +1839,12 @@ dependencies = [
[[package]]
name = "ruma-identifiers-validation"
version = "0.3.0"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
[[package]]
name = "ruma-identity-service-api"
version = "0.1.0-alpha.1"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"js_int",
"ruma-api",
@ -1857,7 +1858,7 @@ dependencies = [
[[package]]
name = "ruma-push-gateway-api"
version = "0.1.0-alpha.1"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"js_int",
"ruma-api",
@ -1872,7 +1873,7 @@ dependencies = [
[[package]]
name = "ruma-serde"
version = "0.3.1"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"bytes",
"form_urlencoded",
@ -1886,7 +1887,7 @@ dependencies = [
[[package]]
name = "ruma-serde-macros"
version = "0.3.1"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"proc-macro-crate",
"proc-macro2",
@ -1897,7 +1898,7 @@ dependencies = [
[[package]]
name = "ruma-signatures"
version = "0.7.0"
source = "git+https://github.com/ruma/ruma?rev=bdb38279c34e423a80533f3f7b0c8cada238559f#bdb38279c34e423a80533f3f7b0c8cada238559f"
source = "git+https://github.com/ruma/ruma?rev=097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2#097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2"
dependencies = [
"base64 0.13.0",
"ring",
@ -2210,7 +2211,7 @@ dependencies = [
[[package]]
name = "state-res"
version = "0.1.0"
source = "git+https://github.com/ruma/state-res?rev=a4d2182d2fb23f5357a6e52179e951acb0dc43cb#a4d2182d2fb23f5357a6e52179e951acb0dc43cb"
source = "git+https://github.com/ruma/state-res?rev=bca91bcc17df4d16942ff8b8c3be622b1795e3f0#bca91bcc17df4d16942ff8b8c3be622b1795e3f0"
dependencies = [
"itertools 0.10.0",
"log",

View file

@ -18,12 +18,12 @@ rocket = { git = "https://github.com/SergioBenitez/Rocket.git", rev = "801e04bd5
#rocket = { git = "https://github.com/timokoesters/Rocket.git", branch = "empty_parameters", default-features = false, features = ["tls"] }
# Used for matrix spec type definitions and helpers
ruma = { git = "https://github.com/ruma/ruma", rev = "bdb38279c34e423a80533f3f7b0c8cada238559f", features = ["client", "compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "unstable-pre-spec", "unstable-exhaustive-types"] }
ruma = { git = "https://github.com/ruma/ruma", rev = "097f20c837fcbaef1d9c18c30d3ec5a24a6e4ec2", features = ["client-reqwest", "compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "unstable-pre-spec", "unstable-exhaustive-types"] }
#ruma = { git = "https://github.com/timokoesters/ruma", rev = "220d5b4a76b3b781f7f8297fbe6b14473b04214b", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "unstable-pre-spec", "unstable-exhaustive-types"] }
#ruma = { path = "../ruma/ruma", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "unstable-pre-spec", "unstable-exhaustive-types"] }
# Used when doing state resolution
state-res = { git = "https://github.com/ruma/state-res", rev = "a4d2182d2fb23f5357a6e52179e951acb0dc43cb", features = ["unstable-pre-spec"] }
state-res = { git = "https://github.com/ruma/state-res", rev = "bca91bcc17df4d16942ff8b8c3be622b1795e3f0", features = ["unstable-pre-spec"] }
#state-res = { path = "../state-res", features = ["unstable-pre-spec"] }
# Used for long polling and federation sender, should be the same as rocket::tokio

View file

@ -22,28 +22,33 @@ where
let destination = registration.get("url").unwrap().as_str().unwrap();
let hs_token = registration.get("hs_token").unwrap().as_str().unwrap();
let mut http_request = request
.try_into_http_request::<BytesMut>(&destination, SendAccessToken::IfRequired(""))
.unwrap()
.map(|body| body.freeze());
globals
.reqwest_client()
.send_customized_matrix_request(
&destination,
SendAccessToken::IfRequired(""),
request,
|http_request| {
let mut parts = http_request.uri().clone().into_parts();
let old_path_and_query = parts.path_and_query.unwrap().as_str().to_owned();
let symbol = if old_path_and_query.contains('?') {
"&"
} else {
"?"
};
let mut parts = http_request.uri().clone().into_parts();
let old_path_and_query = parts.path_and_query.unwrap().as_str().to_owned();
let symbol = if old_path_and_query.contains('?') {
"&"
} else {
"?"
};
parts.path_and_query =
Some((old_path_and_query + symbol + "access_token=" + hs_token).parse()?);
*http_request.uri_mut() = parts.try_into()?;
parts.path_and_query = Some(
(old_path_and_query + symbol + "access_token=" + hs_token)
.parse()
.unwrap(),
);
*http_request.uri_mut() = parts.try_into().expect("our manipulation is always valid");
let mut reqwest_request = reqwest::Request::try_from(http_request)
.expect("all http requests are valid reqwest requests");
Ok(())
},
)
.await
.map_err(|e| {
warn!("Appservice error: {}", e);
Error::BadServerResponse("Server returned an error.")
})?;
*reqwest_request.timeout_mut() = Some(Duration::from_secs(30));