1
0
Fork 0
mirror of https://forgejo.ellis.link/continuwuation/continuwuity.git synced 2025-08-10 15:30:54 +00:00
continuwuity/src/api/server/hierarchy.rs
strawberry 77e0b76408
apply new rustfmt.toml changes, fix some clippy lints
Signed-off-by: strawberry <strawberry@puppygock.gay>
2024-12-15 01:00:41 -05:00

23 lines
718 B
Rust

use axum::extract::State;
use ruma::api::{client::error::ErrorKind, federation::space::get_hierarchy};
use crate::{Error, Result, Ruma};
/// # `GET /_matrix/federation/v1/hierarchy/{roomId}`
///
/// Gets the space tree in a depth-first manner to locate child rooms of a given
/// space.
pub(crate) async fn get_hierarchy_route(
State(services): State<crate::State>,
body: Ruma<get_hierarchy::v1::Request>,
) -> Result<get_hierarchy::v1::Response> {
if services.rooms.metadata.exists(&body.room_id).await {
services
.rooms
.spaces
.get_federation_hierarchy(&body.room_id, body.origin(), body.suggested_only)
.await
} else {
Err(Error::BadRequest(ErrorKind::NotFound, "Room does not exist."))
}
}