matrix-sdk: Disable for now joins by roomid or alias.

This commit is contained in:
Damir Jelić 2020-05-14 14:30:29 +02:00
parent 9884c0bb7a
commit b1de56478d

View file

@ -469,27 +469,29 @@ impl Client {
self.send(request).await self.send(request).await
} }
/// Join a room by `RoomId`. // TODO enable this once Ruma supports proper serialization of the query
/// // string.
/// Returns a `join_room_by_id_or_alias::Response` consisting of the ///// Join a room by `RoomId`.
/// joined rooms `RoomId`. /////
/// ///// Returns a `join_room_by_id_or_alias::Response` consisting of the
/// # Arguments ///// joined rooms `RoomId`.
/// /////
/// * `alias` - The `RoomId` or `RoomAliasId` of the room to be joined. ///// # Arguments
/// An alias looks like this `#name:example.com` /////
pub async fn join_room_by_id_or_alias( ///// * `alias` - The `RoomId` or `RoomAliasId` of the room to be joined.
&self, ///// An alias looks like this `#name:example.com`
alias: &RoomIdOrAliasId, //pub async fn join_room_by_id_or_alias(
server_names: &[String], // &self,
) -> Result<join_room_by_id_or_alias::Response> { // alias: &RoomIdOrAliasId,
let request = join_room_by_id_or_alias::Request { // server_names: &[String],
room_id_or_alias: alias.clone(), //) -> Result<join_room_by_id_or_alias::Response> {
server_name: server_names.to_owned(), // let request = join_room_by_id_or_alias::Request {
third_party_signed: None, // room_id_or_alias: alias.clone(),
}; // server_name: server_names.to_owned(),
self.send(request).await // third_party_signed: None,
} // };
// self.send(request).await
//}
/// Forget a room by `RoomId`. /// Forget a room by `RoomId`.
/// ///
@ -1374,37 +1376,39 @@ mod test {
); );
} }
#[tokio::test] // TODO enable this once Ruma supports proper serialization of the query
async fn join_room_by_id_or_alias() { // string.
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 { // let session = Session {
access_token: "1234".to_owned(), // access_token: "1234".to_owned(),
user_id: UserId::try_from("@example:localhost").unwrap(), // user_id: UserId::try_from("@example:localhost").unwrap(),
device_id: "DEVICEID".to_owned(), // device_id: "DEVICEID".to_owned(),
}; // };
let _m = mock( // let _m = mock(
"POST", // "POST",
Matcher::Regex(r"^/_matrix/client/r0/join/".to_string()), // Matcher::Regex(r"^/_matrix/client/r0/join/".to_string()),
) // )
.with_status(200) // .with_status(200)
.with_body_from_file("../test_data/room_id.json") // .with_body_from_file("../test_data/room_id.json")
.create(); // .create();
let client = Client::new(homeserver, Some(session)).unwrap(); // let client = Client::new(homeserver, Some(session)).unwrap();
let room_id = RoomIdOrAliasId::try_from("!testroom:example.org").unwrap(); // let room_id = RoomIdOrAliasId::try_from("!testroom:example.org").unwrap();
assert_eq!( // assert_eq!(
// this is the `join_by_room_id::Response` but since no PartialEq we check the RoomId field // // this is the `join_by_room_id::Response` but since no PartialEq we check the RoomId field
client // client
.join_room_by_id_or_alias(&room_id, &["server.com".to_string()]) // .join_room_by_id_or_alias(&room_id, &["server.com".to_string()])
.await // .await
.unwrap() // .unwrap()
.room_id, // .room_id,
RoomId::try_from("!testroom:example.org").unwrap() // RoomId::try_from("!testroom:example.org").unwrap()
); // );
} // }
#[tokio::test] #[tokio::test]
#[allow(irrefutable_let_patterns)] #[allow(irrefutable_let_patterns)]