Files
continuwuity/src/api/client/room/summary.rs
T

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

45 lines
1.3 KiB
Rust
Raw Normal View History

use axum::extract::State;
use conduwuit::{Err, Result};
use ruma::api::client::room::get_summary;
use service::rooms::summary::Accessibility;
2026-07-19 10:15:39 -07:00
use crate::{Ruma, router::ClientIdentity};
2025-07-01 01:36:58 +01:00
/// # `GET /_matrix/client/v1/room_summary/{roomIdOrAlias}`
///
/// Returns a short description of the state of a room.
#[tracing::instrument(skip_all, name = "room_summary", level = "info")]
pub(crate) async fn get_room_summary(
State(services): State<crate::State>,
body: Ruma<get_summary::v1::Request>,
) -> Result<get_summary::v1::Response> {
2026-10-12 14:13:15 -04:00
let (room_id, _) = services
.rooms
.alias
.resolve_with_servers(&body.room_id_or_alias, Some(body.via.clone()))
.await?;
if services.rooms.metadata.is_banned(&room_id).await {
return Err!(Request(Forbidden("This room is banned on this homeserver.")));
}
let summary = services
.rooms
.summary
.get_room_summary_for_user(
2026-10-12 14:13:15 -04:00
body.identity.as_ref().and_then(ClientIdentity::sender_user),
&room_id,
2026-10-12 14:13:15 -04:00
&body.via,
)
.await?;
match summary {
| Accessibility::Accessible(summary) => Ok(get_summary::v1::Response::new(summary)),
| Accessibility::Inaccessible => {
Err!(Request(Forbidden("You may not preview this room."), FORBIDDEN))
},
| Accessibility::NotFound => {
2026-11-13 03:35:10 +00:00
Err!(Request(NotFound("This room does not exist.")))
},
}
}