Upgrade ruma

master
Alejandro Domínguez 2020-09-29 17:23:14 +02:00
parent 9a5345ec77
commit b58d88e0c3
6 changed files with 24 additions and 15 deletions

View File

@ -1,4 +1,4 @@
#![type_length_limit = "1700984"] #![type_length_limit = "1702124"]
use matrix_sdk::{ use matrix_sdk::{
api::r0::sync::sync_events::Response as SyncResponse, api::r0::sync::sync_events::Response as SyncResponse,

View File

@ -727,11 +727,12 @@ impl Client {
/// # Examples /// # Examples
/// ```no_run /// ```no_run
/// use matrix_sdk::Client; /// use matrix_sdk::Client;
/// # use std::convert::TryInto;
/// # use url::Url; /// # use url::Url;
/// # let homeserver = Url::parse("http://example.com").unwrap(); /// # let homeserver = Url::parse("http://example.com").unwrap();
/// # let limit = Some(10); /// # let limit = Some(10);
/// # let since = Some("since token"); /// # let since = Some("since token");
/// # let server = Some("server name"); /// # let server = Some("servername.com".try_into().unwrap());
/// ///
/// let mut client = Client::new(homeserver).unwrap(); /// let mut client = Client::new(homeserver).unwrap();
/// # use futures::executor::block_on; /// # use futures::executor::block_on;
@ -744,7 +745,7 @@ impl Client {
&self, &self,
limit: Option<u32>, limit: Option<u32>,
since: Option<&str>, since: Option<&str>,
server: Option<&str>, server: Option<&ServerName>,
) -> Result<get_public_rooms::Response> { ) -> Result<get_public_rooms::Response> {
let limit = limit.map(|n| UInt::try_from(n).ok()).flatten(); let limit = limit.map(|n| UInt::try_from(n).ok()).flatten();

View File

@ -37,6 +37,10 @@ pub enum Error {
#[error("the queried endpoint requires authentication but was called before logging in")] #[error("the queried endpoint requires authentication but was called before logging in")]
AuthenticationRequired, AuthenticationRequired,
/// Queried endpoint is not meant for clients.
#[error("the queried endpoint is not meant for clients")]
NotClientRequest,
/// An error at the HTTP layer. /// An error at the HTTP layer.
#[error(transparent)] #[error(transparent)]
Reqwest(#[from] ReqwestError), Reqwest(#[from] ReqwestError),

View File

@ -19,7 +19,9 @@ use reqwest::{Client, Response};
use tracing::trace; use tracing::trace;
use url::Url; use url::Url;
use matrix_sdk_common::{api::r0::media::create_content, locks::RwLock, FromHttpResponseError}; use matrix_sdk_common::{
api::r0::media::create_content, locks::RwLock, AuthScheme, FromHttpResponseError,
};
use matrix_sdk_common_macros::async_trait; use matrix_sdk_common_macros::async_trait;
use crate::{ClientConfig, Error, OutgoingRequest, Result, Session}; use crate::{ClientConfig, Error, OutgoingRequest, Result, Session};
@ -91,7 +93,8 @@ impl HttpClient {
) -> Result<http::Response<Vec<u8>>> { ) -> Result<http::Response<Vec<u8>>> {
let mut request = { let mut request = {
let read_guard; let read_guard;
let access_token = if Request::METADATA.requires_authentication { let access_token = match Request::METADATA.authentication {
AuthScheme::AccessToken => {
read_guard = session.read().await; read_guard = session.read().await;
if let Some(session) = read_guard.as_ref() { if let Some(session) = read_guard.as_ref() {
@ -99,8 +102,9 @@ impl HttpClient {
} else { } else {
return Err(Error::AuthenticationRequired); return Err(Error::AuthenticationRequired);
} }
} else { }
None AuthScheme::None => None,
_ => return Err(Error::NotClientRequest),
}; };
request.try_into_http_request(&self.homeserver.to_string(), access_token)? request.try_into_http_request(&self.homeserver.to_string(), access_token)?

View File

@ -21,7 +21,7 @@ js_int = "0.1.9"
[dependencies.ruma] [dependencies.ruma]
version = "0.0.1" version = "0.0.1"
git = "https://github.com/ruma/ruma" git = "https://github.com/ruma/ruma"
rev = "4a9b1aeb3c87bd8574391d7084ec5bf109f7d363" rev = "3869d75837b7aab60eef58fc834e498317d1e4a4"
features = ["client-api", "unstable-pre-spec", "unstable-exhaustive-types"] features = ["client-api", "unstable-pre-spec", "unstable-exhaustive-types"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]

View File

@ -5,9 +5,9 @@ pub use ruma::{
api::{ api::{
client as api, client as api,
error::{FromHttpRequestError, FromHttpResponseError, IntoHttpError, ServerError}, error::{FromHttpRequestError, FromHttpResponseError, IntoHttpError, ServerError},
EndpointError, Outgoing, OutgoingRequest, AuthScheme, EndpointError, OutgoingRequest,
}, },
directory, encryption, events, identifiers, presence, push, thirdparty, Raw, directory, encryption, events, identifiers, presence, push, thirdparty, Outgoing, Raw,
}; };
pub use uuid; pub use uuid;