Files
continuwuity/src/api/server/hierarchy.rs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
717 B
Rust
Raw Normal View History

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