Upgrade ruma

next
Jonas Platte 2021-04-23 18:45:06 +02:00 committed by Timo Kösters
parent e72fd44bb5
commit d8b484beed
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4
6 changed files with 2915 additions and 12 deletions

2897
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -18,12 +18,12 @@ rocket = { git = "https://github.com/SergioBenitez/Rocket.git", rev = "e1307ddf4
#rocket = { git = "https://github.com/timokoesters/Rocket.git", branch = "empty_parameters", default-features = false, features = ["tls"] } #rocket = { git = "https://github.com/timokoesters/Rocket.git", branch = "empty_parameters", default-features = false, features = ["tls"] }
# Used for matrix spec type definitions and helpers # Used for matrix spec type definitions and helpers
ruma = { git = "https://github.com/ruma/ruma", rev = "4f16b9357c15d649075393a723f23cf560251754", features = ["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 = "12ec0fb1680ebc4fec4fbefbbd0890ae4eaf3a88", features = ["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 = { 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"] } #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 # Used when doing state resolution
state-res = { git = "https://github.com/ruma/state-res", rev = "aa53d07f51ffb7258f5c1e499bddffd4c630f7df", features = ["unstable-pre-spec"] } state-res = { git = "https://github.com/ruma/state-res", rev = "1dd252d1c97a38def74bc097c197a33179ed8fbb", features = ["unstable-pre-spec"] }
#state-res = { path = "../state-res", 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 # Used for long polling and federation sender, should be the same as rocket::tokio
@ -32,6 +32,8 @@ tokio = "1.2.0"
sled = { version = "0.34.6", features = ["compression", "no_metrics"] } sled = { version = "0.34.6", features = ["compression", "no_metrics"] }
#sled = { git = "https://github.com/spacejam/sled.git", rev = "e4640e0773595229f398438886f19bca6f7326a2", features = ["compression"] } #sled = { git = "https://github.com/spacejam/sled.git", rev = "e4640e0773595229f398438886f19bca6f7326a2", features = ["compression"] }
# Used for the http request / response body type for Ruma endpoints used with reqwest
bytes = "1.0.1"
# Used for emitting log entries # Used for emitting log entries
log = "0.4.14" log = "0.4.14"
# Used for rocket<->ruma conversions # Used for rocket<->ruma conversions

View File

@ -1,7 +1,8 @@
use crate::{utils, Error, Result}; use crate::{utils, Error, Result};
use bytes::BytesMut;
use http::header::{HeaderValue, CONTENT_TYPE}; use http::header::{HeaderValue, CONTENT_TYPE};
use log::warn; use log::warn;
use ruma::api::{IncomingResponse, OutgoingRequest}; use ruma::api::{IncomingResponse, OutgoingRequest, SendAccessToken};
use std::{ use std::{
convert::{TryFrom, TryInto}, convert::{TryFrom, TryInto},
fmt::Debug, fmt::Debug,
@ -20,8 +21,9 @@ where
let hs_token = registration.get("hs_token").unwrap().as_str().unwrap(); let hs_token = registration.get("hs_token").unwrap().as_str().unwrap();
let mut http_request = request let mut http_request = request
.try_into_http_request(&destination, Some("")) .try_into_http_request::<BytesMut>(&destination, SendAccessToken::IfRequired(""))
.unwrap(); .unwrap()
.map(|body| body.freeze());
let mut parts = http_request.uri().clone().into_parts(); let mut parts = http_request.uri().clone().into_parts();
let old_path_and_query = parts.path_and_query.unwrap().as_str().to_owned(); let old_path_and_query = parts.path_and_query.unwrap().as_str().to_owned();

View File

@ -1,4 +1,5 @@
use crate::{Database, Error, PduEvent, Result}; use crate::{Database, Error, PduEvent, Result};
use bytes::BytesMut;
use log::{error, info, warn}; use log::{error, info, warn};
use ruma::{ use ruma::{
api::{ api::{
@ -7,7 +8,7 @@ use ruma::{
self, self,
v1::{Device, Notification, NotificationCounts, NotificationPriority}, v1::{Device, Notification, NotificationCounts, NotificationPriority},
}, },
IncomingResponse, OutgoingRequest, IncomingResponse, OutgoingRequest, SendAccessToken,
}, },
events::{room::power_levels::PowerLevelsEventContent, EventType}, events::{room::power_levels::PowerLevelsEventContent, EventType},
push::{Action, PushConditionRoomCtx, PushFormat, Ruleset, Tweak}, push::{Action, PushConditionRoomCtx, PushFormat, Ruleset, Tweak},
@ -99,11 +100,12 @@ where
let destination = destination.replace("/_matrix/push/v1/notify", ""); let destination = destination.replace("/_matrix/push/v1/notify", "");
let http_request = request let http_request = request
.try_into_http_request(&destination, Some("")) .try_into_http_request::<BytesMut>(&destination, SendAccessToken::IfRequired(""))
.map_err(|e| { .map_err(|e| {
warn!("Failed to find destination {}: {}", destination, e); warn!("Failed to find destination {}: {}", destination, e);
Error::BadServerResponse("Invalid destination") Error::BadServerResponse("Invalid destination")
})?; })?
.map(|body| body.freeze());
let reqwest_request = reqwest::Request::try_from(http_request) let reqwest_request = reqwest::Request::try_from(http_request)
.expect("all http requests are valid reqwest requests"); .expect("all http requests are valid reqwest requests");

View File

@ -316,7 +316,7 @@ where
fn respond_to(self, _: &'r Request<'_>) -> response::Result<'o> { fn respond_to(self, _: &'r Request<'_>) -> response::Result<'o> {
let http_response = self let http_response = self
.0 .0
.try_into_http_response() .try_into_http_response::<Vec<u8>>()
.map_err(|_| Status::InternalServerError)?; .map_err(|_| Status::InternalServerError)?;
let mut response = rocket::response::Response::build(); let mut response = rocket::response::Response::build();

View File

@ -23,7 +23,7 @@ use ruma::{
query::{get_profile_information, get_room_information}, query::{get_profile_information, get_room_information},
transactions::{edu::Edu, send_transaction_message}, transactions::{edu::Edu, send_transaction_message},
}, },
IncomingResponse, OutgoingRequest, OutgoingResponse, IncomingResponse, OutgoingRequest, OutgoingResponse, SendAccessToken,
}, },
directory::{IncomingFilter, IncomingRoomNetwork}, directory::{IncomingFilter, IncomingRoomNetwork},
events::{ events::{
@ -141,7 +141,7 @@ where
}; };
let mut http_request = request let mut http_request = request
.try_into_http_request(&actual_destination, Some("")) .try_into_http_request::<Vec<u8>>(&actual_destination, SendAccessToken::IfRequired(""))
.map_err(|e| { .map_err(|e| {
warn!("Failed to find destination {}: {}", actual_destination, e); warn!("Failed to find destination {}: {}", actual_destination, e);
Error::BadServerResponse("Invalid destination") Error::BadServerResponse("Invalid destination")
@ -454,7 +454,7 @@ pub fn get_server_keys_route(db: State<'_, Database>) -> Json<String> {
valid_until_ts: SystemTime::now() + Duration::from_secs(60 * 2), valid_until_ts: SystemTime::now() + Duration::from_secs(60 * 2),
}, },
} }
.try_into_http_response() .try_into_http_response::<Vec<u8>>()
.unwrap() .unwrap()
.body(), .body(),
) )