matrix-sdk: Re-enable joins by id or alias.

master
Damir Jelić 2020-05-15 12:32:36 +02:00
parent 458923d313
commit e51e89d9d5
6 changed files with 76 additions and 76 deletions

View File

@ -19,9 +19,9 @@ sqlite-cryptostore = ["matrix-sdk-base/sqlite-cryptostore"]
[dependencies]
http = "0.2.1"
reqwest = "0.10.4"
serde_json = "1.0.52"
thiserror = "1.0.16"
tracing = "0.1.13"
serde_json = "1.0.53"
thiserror = "1.0.17"
tracing = "0.1.14"
url = "2.1.1"
futures-timer = "3.0.2"
@ -39,14 +39,14 @@ default-features = false
features = ["std", "std-future"]
[dev-dependencies]
async-trait = "0.1.30"
async-trait = "0.1.31"
dirs = "2.0.2"
matrix-sdk-test = { version = "0.1.0", path = "../matrix_sdk_test" }
tokio = { version = "0.2.20", features = ["rt-threaded", "macros"] }
tokio = { version = "0.2.21", features = ["rt-threaded", "macros"] }
ruma-identifiers = { version = "0.16.1", features = ["rand"] }
serde_json = "1.0.52"
serde_json = "1.0.53"
tracing-subscriber = "0.2.5"
tempfile = "3.1.0"
mockito = "0.25.1"
lazy_static = "1.4.0"
futures = "0.3.4"
futures = "0.3.5"

View File

@ -37,7 +37,7 @@ use url::Url;
use crate::events::room::message::MessageEventContent;
use crate::events::EventType;
use crate::identifiers::{EventId, RoomId, UserId};
use crate::identifiers::{EventId, RoomId, RoomIdOrAliasId, UserId};
use crate::Endpoint;
#[cfg(feature = "encryption")]
@ -224,7 +224,7 @@ use api::r0::keys::{claim_keys, get_keys, upload_keys, KeyAlgorithm};
use api::r0::membership::{
ban_user, forget_room,
invite_user::{self, InvitationRecipient},
join_room_by_id, kick_user, leave_room, Invite3pid,
join_room_by_id, join_room_by_id_or_alias, kick_user, leave_room, Invite3pid,
};
use api::r0::message::create_message_event;
use api::r0::message::get_message_events;
@ -473,27 +473,27 @@ impl Client {
// TODO enable this once Ruma supports proper serialization of the query
// string.
///// Join a room by `RoomId`.
/////
///// Returns a `join_room_by_id_or_alias::Response` consisting of the
///// joined rooms `RoomId`.
/////
///// # Arguments
/////
///// * `alias` - The `RoomId` or `RoomAliasId` of the room to be joined.
///// An alias looks like this `#name:example.com`
//pub async fn join_room_by_id_or_alias(
// &self,
// alias: &RoomIdOrAliasId,
// server_names: &[String],
//) -> Result<join_room_by_id_or_alias::Response> {
// let request = join_room_by_id_or_alias::Request {
// room_id_or_alias: alias.clone(),
// server_name: server_names.to_owned(),
// third_party_signed: None,
// };
// self.send(request).await
//}
/// Join a room by `RoomId`.
///
/// Returns a `join_room_by_id_or_alias::Response` consisting of the
/// joined rooms `RoomId`.
///
/// # Arguments
///
/// * `alias` - The `RoomId` or `RoomAliasId` of the room to be joined.
/// An alias looks like this `#name:example.com`
pub async fn join_room_by_id_or_alias(
&self,
alias: &RoomIdOrAliasId,
server_names: &[String],
) -> Result<join_room_by_id_or_alias::Response> {
let request = join_room_by_id_or_alias::Request {
room_id_or_alias: alias.clone(),
server_name: server_names.to_owned(),
third_party_signed: None,
};
self.send(request).await
}
/// Forget a room by `RoomId`.
///
@ -1240,7 +1240,7 @@ mod test {
use crate::events::collections::all::RoomEvent;
use crate::events::room::member::MembershipState;
use crate::events::room::message::TextMessageEventContent;
use crate::identifiers::{EventId, RoomId, UserId};
use crate::identifiers::{EventId, RoomId, RoomIdOrAliasId, UserId};
use matrix_sdk_base::JsonStore;
use matrix_sdk_test::{EventBuilder, EventsFile};
@ -1380,37 +1380,37 @@ mod test {
// TODO enable this once Ruma supports proper serialization of the query
// string.
// #[tokio::test]
// async fn join_room_by_id_or_alias() {
// let homeserver = Url::from_str(&mockito::server_url()).unwrap();
#[tokio::test]
async fn join_room_by_id_or_alias() {
let homeserver = Url::from_str(&mockito::server_url()).unwrap();
// let session = Session {
// access_token: "1234".to_owned(),
// user_id: UserId::try_from("@example:localhost").unwrap(),
// device_id: "DEVICEID".to_owned(),
// };
let session = Session {
access_token: "1234".to_owned(),
user_id: UserId::try_from("@example:localhost").unwrap(),
device_id: "DEVICEID".to_owned(),
};
// let _m = mock(
// "POST",
// Matcher::Regex(r"^/_matrix/client/r0/join/".to_string()),
// )
// .with_status(200)
// .with_body_from_file("../test_data/room_id.json")
// .create();
let _m = mock(
"POST",
Matcher::Regex(r"^/_matrix/client/r0/join/".to_string()),
)
.with_status(200)
.with_body_from_file("../test_data/room_id.json")
.create();
// let client = Client::new(homeserver, Some(session)).unwrap();
// let room_id = RoomIdOrAliasId::try_from("!testroom:example.org").unwrap();
let client = Client::new(homeserver, Some(session)).unwrap();
let room_id = RoomIdOrAliasId::try_from("!testroom:example.org").unwrap();
// assert_eq!(
// // this is the `join_by_room_id::Response` but since no PartialEq we check the RoomId field
// client
// .join_room_by_id_or_alias(&room_id, &["server.com".to_string()])
// .await
// .unwrap()
// .room_id,
// RoomId::try_from("!testroom:example.org").unwrap()
// );
// }
assert_eq!(
// this is the `join_by_room_id::Response` but since no PartialEq we check the RoomId field
client
.join_room_by_id_or_alias(&room_id, &["server.com".to_string()])
.await
.unwrap()
.room_id,
RoomId::try_from("!testroom:example.org").unwrap()
);
}
#[tokio::test]
#[allow(irrefutable_let_patterns)]

View File

@ -17,18 +17,18 @@ encryption = ["matrix-sdk-crypto"]
sqlite-cryptostore = ["matrix-sdk-crypto/sqlite-cryptostore"]
[dependencies]
async-trait = "0.1.30"
serde = "1.0.106"
serde_json = "1.0.52"
async-trait = "0.1.31"
serde = "1.0.110"
serde_json = "1.0.53"
matrix-sdk-common = { version = "0.1.0", path = "../matrix_sdk_common" }
matrix-sdk-crypto = { version = "0.1.0", path = "../matrix_sdk_crypto", optional = true }
# Misc dependencies
thiserror = "1.0.16"
thiserror = "1.0.17"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]
version = "0.2.20"
version = "0.2.21"
default-features = false
features = ["sync", "fs"]
@ -40,7 +40,7 @@ tracing-subscriber = "0.2.5"
tempfile = "3.1.0"
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
tokio = { version = "0.2.20", features = ["rt-threaded", "macros"] }
tokio = { version = "0.2.21", features = ["rt-threaded", "macros"] }
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3.12"

View File

@ -12,7 +12,7 @@ version = "0.1.0"
[dependencies]
js_int = "0.1.5"
ruma-api = "0.16.0"
ruma-api = "0.16.1"
ruma-client-api = "0.8.0"
ruma-events = "0.21.1"
ruma-identifiers = "0.16.1"
@ -22,7 +22,7 @@ instant = { version = "0.1.3", features = ["wasm-bindgen", "now"] }
uuid = { version = "0.8.1", features = ["v4"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]
version = "0.2.20"
version = "0.2.21"
default-features = false
features = ["sync", "time", "fs"]

View File

@ -15,20 +15,20 @@ default = []
sqlite-cryptostore = ["sqlx"]
[dependencies]
async-trait = "0.1.30"
async-trait = "0.1.31"
matrix-sdk-common = { version = "0.1.0", path = "../matrix_sdk_common" }
olm-rs = { version = "0.5.0", features = ["serde"] }
serde = { version = "1.0.106", features = ["derive"] }
serde_json = "1.0.52"
serde = { version = "1.0.110", features = ["derive"] }
serde_json = "1.0.53"
cjson = "0.1.0"
zeroize = { version = "1.1.0", features = ["zeroize_derive"] }
url = "2.1.1"
# Misc dependencies
thiserror = "1.0.16"
tracing = "0.1.13"
thiserror = "1.0.17"
tracing = "0.1.14"
atomic = "0.4.5"
dashmap = "3.11.1"
@ -44,8 +44,8 @@ default-features = false
features = ["runtime-tokio", "sqlite"]
[dev-dependencies]
tokio = { version = "0.2.20", features = ["rt-threaded", "macros"] }
tokio = { version = "0.2.21", features = ["rt-threaded", "macros"] }
ruma-identifiers = { version = "0.16.1", features = ["rand"] }
serde_json = "1.0.52"
serde_json = "1.0.53"
tempfile = "3.1.0"
http = "0.2.1"

View File

@ -11,7 +11,7 @@ repository = "https://github.com/matrix-org/matrix-rust-sdk"
version = "0.1.0"
[dependencies]
serde_json = "1.0.52"
serde_json = "1.0.53"
http = "0.2.1"
matrix-sdk-common = { version = "0.1.0", path = "../matrix_sdk_common" }
matrix-sdk-test-macros = { path = "../matrix_sdk_test_macros" }