mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-06-28 08:14:22 +02:00
19 lines
823 B
Rust
19 lines
823 B
Rust
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<get_hierarchy::v1::Request>) -> Result<get_hierarchy::v1::Response> {
|
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
|
|
|
let skip = body.from.as_ref().and_then(|s| s.parse::<usize>().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
|
|
}
|