use ruma::api::client::space::get_hierarchy; use crate::{services, Result, Ruma}; /// # `GET /_matrix/client/v1/rooms/{room_id}/hierarchy`` /// /// Paginates over the space tree in a depth-first manner to locate child rooms /// of a given space. pub async fn get_hierarchy_route(body: Ruma) -> Result { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let skip = body.from.as_ref().and_then(|s| s.parse::().ok()).unwrap_or(0); let limit = body.limit.map_or(10, u64::from).min(100) as usize; let max_depth = body.max_depth.map_or(3, u64::from).min(10) as usize + 1; // +1 to skip the space room itself services().rooms.spaces.get_hierarchy(sender_user, &body.room_id, limit, skip, max_depth, body.suggested_only).await }