|
|
|
|
@ -8,6 +8,7 @@ use ruma::{
@@ -8,6 +8,7 @@ use ruma::{
|
|
|
|
|
api::{ |
|
|
|
|
client::error::ErrorKind, |
|
|
|
|
federation::{ |
|
|
|
|
device::get_devices::{self, v1::UserDevice}, |
|
|
|
|
directory::{get_public_rooms, get_public_rooms_filtered}, |
|
|
|
|
discovery::{ |
|
|
|
|
get_remote_server_keys, get_server_keys, get_server_version, ServerSigningKeys, |
|
|
|
|
@ -861,8 +862,6 @@ fn handle_incoming_pdu<'a>(
@@ -861,8 +862,6 @@ fn handle_incoming_pdu<'a>(
|
|
|
|
|
.collect(), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
&state_at_incoming_event; |
|
|
|
|
|
|
|
|
|
// TODO: set incoming_auth_events?
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1859,12 +1858,12 @@ pub async fn create_join_event_route<'a>(
@@ -1859,12 +1858,12 @@ pub async fn create_join_event_route<'a>(
|
|
|
|
|
auth_chain: auth_chain_ids |
|
|
|
|
.iter() |
|
|
|
|
.filter_map(|id| db.rooms.get_pdu_json(&id).ok().flatten()) |
|
|
|
|
.map(|json| PduEvent::convert_to_outgoing_federation_event(json)) |
|
|
|
|
.map(PduEvent::convert_to_outgoing_federation_event) |
|
|
|
|
.collect(), |
|
|
|
|
state: state_ids |
|
|
|
|
.iter() |
|
|
|
|
.filter_map(|id| db.rooms.get_pdu_json(&id).ok().flatten()) |
|
|
|
|
.map(|json| PduEvent::convert_to_outgoing_federation_event(json)) |
|
|
|
|
.map(PduEvent::convert_to_outgoing_federation_event) |
|
|
|
|
.collect(), |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
@ -1979,6 +1978,46 @@ pub async fn create_invite_route<'a>(
@@ -1979,6 +1978,46 @@ pub async fn create_invite_route<'a>(
|
|
|
|
|
.into()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[cfg_attr(
|
|
|
|
|
feature = "conduit_bin", |
|
|
|
|
get("/_matrix/federation/v1/user/devices/<_>", data = "<body>") |
|
|
|
|
)] |
|
|
|
|
#[tracing::instrument(skip(db, body))] |
|
|
|
|
pub fn get_devices_route<'a>( |
|
|
|
|
db: State<'a, Database>, |
|
|
|
|
body: Ruma<get_devices::v1::Request<'_>>, |
|
|
|
|
) -> ConduitResult<get_devices::v1::Response> { |
|
|
|
|
if !db.globals.allow_federation() { |
|
|
|
|
return Err(Error::bad_config("Federation is disabled.")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Ok(get_devices::v1::Response { |
|
|
|
|
user_id: body.user_id.clone(), |
|
|
|
|
stream_id: db |
|
|
|
|
.users |
|
|
|
|
.get_devicelist_version(&body.user_id)? |
|
|
|
|
.unwrap_or(0) |
|
|
|
|
.try_into() |
|
|
|
|
.expect("version will not grow that large"), |
|
|
|
|
devices: db |
|
|
|
|
.users |
|
|
|
|
.all_devices_metadata(&body.user_id) |
|
|
|
|
.filter_map(|r| r.ok()) |
|
|
|
|
.filter_map(|metadata| { |
|
|
|
|
Some(UserDevice { |
|
|
|
|
keys: db |
|
|
|
|
.users |
|
|
|
|
.get_device_keys(&body.user_id, &metadata.device_id) |
|
|
|
|
.ok()??, |
|
|
|
|
device_id: metadata.device_id, |
|
|
|
|
device_display_name: metadata.display_name, |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
.collect(), |
|
|
|
|
} |
|
|
|
|
.into()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[cfg_attr(
|
|
|
|
|
feature = "conduit_bin", |
|
|
|
|
get("/_matrix/federation/v1/query/directory", data = "<body>") |
|
|
|
|
@ -1995,7 +2034,7 @@ pub fn get_room_information_route<'a>(
@@ -1995,7 +2034,7 @@ pub fn get_room_information_route<'a>(
|
|
|
|
|
let room_id = db |
|
|
|
|
.rooms |
|
|
|
|
.id_from_alias(&body.room_alias)? |
|
|
|
|
.ok_or_else(|| Error::BadRequest(ErrorKind::NotFound, "Room alias not found."))?; |
|
|
|
|
.ok_or(Error::BadRequest(ErrorKind::NotFound, "Room alias not found."))?; |
|
|
|
|
|
|
|
|
|
Ok(get_room_information::v1::Response { |
|
|
|
|
room_id, |
|
|
|
|
|