|
|
|
@ -38,7 +38,7 @@ use ruma_identifiers::{RoomId, UserId}; |
|
|
|
use serde_json::json; |
|
|
|
use serde_json::json; |
|
|
|
use std::{ |
|
|
|
use std::{ |
|
|
|
collections::BTreeMap, |
|
|
|
collections::BTreeMap, |
|
|
|
convert::TryInto, |
|
|
|
convert::{TryFrom, TryInto}, |
|
|
|
path::PathBuf, |
|
|
|
path::PathBuf, |
|
|
|
time::{Duration, SystemTime}, |
|
|
|
time::{Duration, SystemTime}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
@ -325,8 +325,7 @@ pub fn set_displayname_route( |
|
|
|
if displayname == "" { |
|
|
|
if displayname == "" { |
|
|
|
data.displayname_remove(&user_id); |
|
|
|
data.displayname_remove(&user_id); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
data.displayname_set(&user_id, body.displayname.clone()); |
|
|
|
data.displayname_set(&user_id, displayname.clone()); |
|
|
|
// TODO send a new m.room.member join event with the updated displayname
|
|
|
|
|
|
|
|
// TODO send a new m.presence event with the updated displayname
|
|
|
|
// TODO send a new m.presence event with the updated displayname
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -610,13 +609,18 @@ pub fn create_room_route( |
|
|
|
MatrixResult(Ok(create_room::Response { room_id })) |
|
|
|
MatrixResult(Ok(create_room::Response { room_id })) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[get("/_matrix/client/r0/directory/room/<room_alias>")] |
|
|
|
#[get("/_matrix/client/r0/directory/room/<_room_alias>", data = "<body>")] |
|
|
|
pub fn get_alias_route(room_alias: String) -> MatrixResult<get_alias::Response> { |
|
|
|
pub fn get_alias_route( |
|
|
|
|
|
|
|
data: State<Data>, |
|
|
|
|
|
|
|
body: Ruma<get_alias::Request>, |
|
|
|
|
|
|
|
_room_alias: String, |
|
|
|
|
|
|
|
) -> MatrixResult<get_alias::Response> { |
|
|
|
// TODO
|
|
|
|
// TODO
|
|
|
|
let room_id = match &*room_alias { |
|
|
|
let room_id = if body.room_alias.server_name() == data.hostname() { |
|
|
|
"#room:localhost" => "!xclkjvdlfj:localhost", |
|
|
|
match body.room_alias.alias() { |
|
|
|
|
|
|
|
"conduit" => "!lgOCCXQKtXOAPlAlG5:conduit.rs", |
|
|
|
_ => { |
|
|
|
_ => { |
|
|
|
debug!("Room not found."); |
|
|
|
debug!("Room alias not found."); |
|
|
|
return MatrixResult(Err(Error { |
|
|
|
return MatrixResult(Err(Error { |
|
|
|
kind: ErrorKind::NotFound, |
|
|
|
kind: ErrorKind::NotFound, |
|
|
|
message: "Room not found.".to_owned(), |
|
|
|
message: "Room not found.".to_owned(), |
|
|
|
@ -624,12 +628,15 @@ pub fn get_alias_route(room_alias: String) -> MatrixResult<get_alias::Response> |
|
|
|
})); |
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
todo!("ask remote server"); |
|
|
|
|
|
|
|
} |
|
|
|
.try_into() |
|
|
|
.try_into() |
|
|
|
.unwrap(); |
|
|
|
.unwrap(); |
|
|
|
|
|
|
|
|
|
|
|
MatrixResult(Ok(get_alias::Response { |
|
|
|
MatrixResult(Ok(get_alias::Response { |
|
|
|
room_id, |
|
|
|
room_id, |
|
|
|
servers: vec!["localhost".to_owned()], |
|
|
|
servers: vec!["conduit.rs".to_owned()], |
|
|
|
})) |
|
|
|
})) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -661,21 +668,19 @@ pub fn join_room_by_id_or_alias_route( |
|
|
|
body: Ruma<join_room_by_id_or_alias::Request>, |
|
|
|
body: Ruma<join_room_by_id_or_alias::Request>, |
|
|
|
_room_id_or_alias: String, |
|
|
|
_room_id_or_alias: String, |
|
|
|
) -> MatrixResult<join_room_by_id_or_alias::Response> { |
|
|
|
) -> MatrixResult<join_room_by_id_or_alias::Response> { |
|
|
|
let room_id = if body.room_id_or_alias.is_room_alias_id() { |
|
|
|
let room_id = match RoomId::try_from(body.room_id_or_alias.clone()) { |
|
|
|
match body.room_id_or_alias.as_ref() { |
|
|
|
Ok(room_id) => room_id, |
|
|
|
"#room:localhost" => "!xclkjvdlfj:localhost".try_into().unwrap(), |
|
|
|
Err(room_alias) => if room_alias.server_name() == data.hostname() { |
|
|
|
_ => { |
|
|
|
|
|
|
|
debug!("Room not found."); |
|
|
|
|
|
|
|
return MatrixResult(Err(Error { |
|
|
|
return MatrixResult(Err(Error { |
|
|
|
kind: ErrorKind::NotFound, |
|
|
|
kind: ErrorKind::NotFound, |
|
|
|
message: "Room not found.".to_owned(), |
|
|
|
message: "Room alias not found.".to_owned(), |
|
|
|
status_code: http::StatusCode::NOT_FOUND, |
|
|
|
status_code: http::StatusCode::NOT_FOUND, |
|
|
|
})); |
|
|
|
})); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
// Ask creator server of the room to join TODO ask someone else when not available
|
|
|
|
|
|
|
|
//server_server::send_request(data, destination, request)
|
|
|
|
todo!(); |
|
|
|
todo!(); |
|
|
|
//body.room_id_or_alias.try_into().unwrap()
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if data.room_join( |
|
|
|
if data.room_join( |
|
|
|
@ -758,9 +763,9 @@ pub async fn get_public_rooms_filtered_route( |
|
|
|
chunk.extend_from_slice( |
|
|
|
chunk.extend_from_slice( |
|
|
|
&server_server::send_request( |
|
|
|
&server_server::send_request( |
|
|
|
&data, |
|
|
|
&data, |
|
|
|
"chat.privacytools.io".to_owned(), |
|
|
|
"privacytools.io".to_owned(), |
|
|
|
ruma_federation_api::v1::get_public_rooms::Request { |
|
|
|
ruma_federation_api::v1::get_public_rooms::Request { |
|
|
|
limit: None, |
|
|
|
limit: Some(20_u32.into()), |
|
|
|
since: None, |
|
|
|
since: None, |
|
|
|
include_all_networks: None, |
|
|
|
include_all_networks: None, |
|
|
|
third_party_instance_id: None, |
|
|
|
third_party_instance_id: None, |
|
|
|
|