From 1e34bd2ed97ea84a2f74101dd944c0156206278b Mon Sep 17 00:00:00 2001 From: Jade Ellis Date: Mon, 5 Oct 2026 00:27:12 +0100 Subject: [PATCH] style: Run formatting --- src/api/client/directory.rs | 12 +++- src/api/client/oauth/mod.rs | 5 +- src/api/client/sync/v5.rs | 29 +++++---- src/api/router.rs | 17 +++--- src/service/oauth/mod.rs | 3 +- src/service/registration_tokens/mod.rs | 8 ++- src/service/rooms/summary/mod.rs | 85 +++++++++++++------------- src/service/rooms/timeline/append.rs | 9 ++- src/service/users/keys.rs | 7 ++- 9 files changed, 106 insertions(+), 69 deletions(-) diff --git a/src/api/client/directory.rs b/src/api/client/directory.rs index a4d137202..2c1607280 100644 --- a/src/api/client/directory.rs +++ b/src/api/client/directory.rs @@ -267,11 +267,19 @@ pub(crate) async fn get_public_rooms_filtered_helper( summary.into() }) .ready_filter_map(|chunk: PublicRoomsChunk| { - if !filter.room_types.is_empty() && !filter.room_types.contains(&RoomTypeFilter::from(chunk.room_type.clone())) { + if !filter.room_types.is_empty() + && !filter + .room_types + .contains(&RoomTypeFilter::from(chunk.room_type.clone())) + { return None; } - if let Some(query) = filter.generic_search_term.as_ref().map(|q| q.to_lowercase()) { + if let Some(query) = filter + .generic_search_term + .as_ref() + .map(|q| q.to_lowercase()) + { if let Some(name) = &chunk.name { if name.to_lowercase().contains(&query) { return Some(chunk); diff --git a/src/api/client/oauth/mod.rs b/src/api/client/oauth/mod.rs index 48f58d32b..b47f717c1 100644 --- a/src/api/client/oauth/mod.rs +++ b/src/api/client/oauth/mod.rs @@ -55,5 +55,8 @@ fn oauth_router() -> Router { .route(concat!("/", JWKS_URI_PATH), get(async || Json(json!({"keys": []})))) .route(concat!("/", TOKEN_PATH), post(token::token_route)) .route(concat!("/", TOKEN_REVOKE_PATH), post(token::revoke_token_route)) - .route(concat!("/", DEVICE_AUTHORIZATION_PATH), post(device::device_authorization_route)) + .route( + concat!("/", DEVICE_AUTHORIZATION_PATH), + post(device::device_authorization_route), + ) } diff --git a/src/api/client/sync/v5.rs b/src/api/client/sync/v5.rs index f75785c86..7f8997aec 100644 --- a/src/api/client/sync/v5.rs +++ b/src/api/client/sync/v5.rs @@ -1563,20 +1563,25 @@ async fn collect_e2ee<'a, Rooms>( // joined users device_list_changes.extend( services - .rooms - .state_cache - .room_members(room_id) - // Don't send key updates from the sender to the sender - .ready_filter(|user_id| sender_user != *user_id) - // Only send keys if the sender doesn't share an encrypted room with the target - // already - .filter_map(async |user_id| { - share_encrypted_room(services, sender_user, &user_id, Some(room_id)) + .rooms + .state_cache + .room_members(room_id) + // Don't send key updates from the sender to the sender + .ready_filter(|user_id| sender_user != *user_id) + // Only send keys if the sender doesn't share an encrypted room with + // the target already + .filter_map(async |user_id| { + share_encrypted_room( + services, + sender_user, + &user_id, + Some(room_id), + ) .map(|res| res.or_some(user_id.clone())) .await - }) - .collect::>() - .await, + }) + .collect::>() + .await, ); } } diff --git a/src/api/router.rs b/src/api/router.rs index a7f8c6145..1912f096a 100644 --- a/src/api/router.rs +++ b/src/api/router.rs @@ -21,7 +21,7 @@ pub fn build(router: Router, state: State) -> Router { let config = &state.server.config; let mut router = router - .ruma_route(&client::appservice_ping) + .ruma_route(&client::appservice_ping) .ruma_route(&client::get_supported_versions_route) .ruma_route(&client::get_register_available_route) .ruma_route(&client::register::register_route) @@ -61,8 +61,8 @@ pub fn build(router: Router, state: State) -> Router { .ruma_route(&client::get_global_account_data_route) .ruma_route(&client::get_room_account_data_route) .ruma_route(&client::get_profile_field_route) - .ruma_route(&client::set_profile_field_route) - .ruma_route(&client::delete_profile_field_route) + .ruma_route(&client::set_profile_field_route) + .ruma_route(&client::delete_profile_field_route) .ruma_route(&client::get_profile_route) .ruma_route(&client::set_presence_route) .ruma_route(&client::get_presence_route) @@ -112,14 +112,17 @@ pub fn build(router: Router, state: State) -> Router { .ruma_route(&client::search_users_route) .ruma_route(&client::get_member_events_route) .ruma_route(&client::get_protocols_route) - .route("/_matrix/client/unstable/thirdparty/protocols", - get(client::get_protocols_route_unstable)) + .route( + "/_matrix/client/unstable/thirdparty/protocols", + get(client::get_protocols_route_unstable), + ) .ruma_route(&client::send_message_event_route) .ruma_route(&client::send_state_event_for_key_route) .ruma_route(&client::get_state_events_route) .ruma_route(&client::get_state_event_for_key_route) - // Ruma doesn't have support for multiple paths for a single endpoint yet, and these routes - // share one Ruma request / response type pair with {get,send}_state_event_for_key_route + // Ruma doesn't have support for multiple paths for a single endpoint yet, and these + // routes share one Ruma request / response type pair with + // {get,send}_state_event_for_key_route .route( "/_matrix/client/r0/rooms/{room_id}/state/{event_type}", get(client::get_state_events_for_empty_key_route) diff --git a/src/service/oauth/mod.rs b/src/service/oauth/mod.rs index 138583a09..b5e576f41 100644 --- a/src/service/oauth/mod.rs +++ b/src/service/oauth/mod.rs @@ -571,7 +571,8 @@ async fn create_session( )); } - let device_id = self.services + let device_id = self + .services .users .create_device( &authorizing_user, diff --git a/src/service/registration_tokens/mod.rs b/src/service/registration_tokens/mod.rs index a6644cd46..1b1fbf158 100644 --- a/src/service/registration_tokens/mod.rs +++ b/src/service/registration_tokens/mod.rs @@ -72,7 +72,10 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { impl crate::Service for Service { fn build(args: crate::Args<'_>) -> Result> { - let registration_tokens_from_file = args.server.config.registration_token_file + let registration_tokens_from_file = args + .server + .config + .registration_token_file .clone() // If the token file option was set, read the path it points to .map(std::fs::read_to_string) @@ -80,7 +83,8 @@ fn build(args: crate::Args<'_>) -> Result> { .map_err(|err| err!("Failed to read registration token file: {err}")) .map(|tokens| { if let Some(tokens) = tokens { - // If the token file option was set, return the file's lines as tokens + // If the token file option was set, return the file's lines + // as tokens tokens.lines().map(ToOwned::to_owned).collect() } else { // Otherwise, if the option wasn't set, return no tokens diff --git a/src/service/rooms/summary/mod.rs b/src/service/rooms/summary/mod.rs index 15953abe5..f2d56eb52 100644 --- a/src/service/rooms/summary/mod.rs +++ b/src/service/rooms/summary/mod.rs @@ -164,12 +164,12 @@ async fn get_room_summary_and_children_for_user( } let mut children: Vec<_> = summary - .children_state - .iter() - // Ignore deserialization failures - .flat_map(Raw::deserialize) - // Filter out non-suggested children if suggested_only is set - .filter(|child| !suggested_only || child.content.suggested) + .children_state + .iter() + // Ignore deserialization failures + .flat_map(Raw::deserialize) + // Filter out non-suggested children if suggested_only is set + .filter(|child| !suggested_only || child.content.suggested) .collect(); children.sort(); let children = children @@ -323,43 +323,46 @@ pub async fn get_local_room_summary_for_server( }; let (accessible_children, inaccessible_children) = children_state - .iter() - // Ignore deserialization failures - .flat_map(Raw::deserialize) - // Fetch summaries for the children in parallel - .stream() - .broad_then(async |child| { - let summary = { - if let Some(summary) = self.build_local_room_summary(&child.state_key).await { - if self.server_may_see_summary(querying_server, &summary).await { - Accessibility::Accessible(summary) - } else { - Accessibility::Inaccessible - } - } else { - Accessibility::NotFound - } - }; + .iter() + // Ignore deserialization failures + .flat_map(Raw::deserialize) + // Fetch summaries for the children in parallel + .stream() + .broad_then(async |child| { + let summary = { + if let Some(summary) = self.build_local_room_summary(&child.state_key).await { + if self.server_may_see_summary(querying_server, &summary).await { + Accessibility::Accessible(summary) + } else { + Accessibility::Inaccessible + } + } else { + Accessibility::NotFound + } + }; - (child.state_key, summary) - }) - // Sort the children into two Vecs by accessibility - .ready_fold_default(|(mut accessible_children, mut inaccessible_children): (Vec<_>, Vec<_>), (room_id, summary)| { - match summary { - Accessibility::Accessible(summary) => { - accessible_children.push(summary); - }, - Accessibility::Inaccessible => { - inaccessible_children.push(room_id); - }, - Accessibility::NotFound => { - // Skip inaccessible children - } - } + (child.state_key, summary) + }) + // Sort the children into two Vecs by accessibility + .ready_fold_default( + |(mut accessible_children, mut inaccessible_children): (Vec<_>, Vec<_>), + (room_id, summary)| { + match summary { + | Accessibility::Accessible(summary) => { + accessible_children.push(summary); + }, + | Accessibility::Inaccessible => { + inaccessible_children.push(room_id); + }, + | Accessibility::NotFound => { + // Skip inaccessible children + }, + } - (accessible_children, inaccessible_children) - }) - .await; + (accessible_children, inaccessible_children) + }, + ) + .await; Accessibility::Accessible(assign!( get_hierarchy::v1::Response::new(SpaceHierarchyParentSummary::new(summary, children_state)), diff --git a/src/service/rooms/timeline/append.rs b/src/service/rooms/timeline/append.rs index bb8f87c22..9639e6733 100644 --- a/src/service/rooms/timeline/append.rs +++ b/src/service/rooms/timeline/append.rs @@ -449,7 +449,12 @@ async fn notify_local_users(&self, pdu: &PduEvent, pdu_id: &RawPduId, room_id: & // Don't notify the sender of their own events, and don't send from ignored users .ready_filter(|user| *user != pdu.sender()) .filter_map(|recipient_user| async move { - (!self.services.users.user_is_ignored(pdu.sender(), &recipient_user).await).then_some(recipient_user) + (!self + .services + .users + .user_is_ignored(pdu.sender(), &recipient_user) + .await) + .then_some(recipient_user) }) .collect() .await; @@ -806,7 +811,7 @@ async fn send_to_interested_appservices( .read() .await .values() - .map(ToOwned::to_owned) // TODO: is this to_owned expensive? + .map(ToOwned::to_owned) // TODO: is this to_owned expensive? .collect::>(); interested_appservices .stream() diff --git a/src/service/users/keys.rs b/src/service/users/keys.rs index 39ec90561..2f0227d14 100644 --- a/src/service/users/keys.rs +++ b/src/service/users/keys.rs @@ -449,7 +449,12 @@ pub async fn mark_device_key_update(&self, user_id: &UserId) { .rooms_joined(user_id) // Don't send key updates to unencrypted rooms .filter_map(async |room_id| { - if self.services.state_accessor.is_encrypted_room(&room_id).await { + if self + .services + .state_accessor + .is_encrypted_room(&room_id) + .await + { Some(room_id) } else { None