2024-11-06 18:27:40 +00:00
|
|
|
use axum::extract::State;
|
2025-04-26 23:50:03 +00:00
|
|
|
use conduwuit::{Err, Result};
|
2024-11-06 18:27:40 +00:00
|
|
|
use futures::StreamExt;
|
2025-04-26 23:50:03 +00:00
|
|
|
use ruma::api::client::room::aliases;
|
2024-11-06 18:27:40 +00:00
|
|
|
|
|
|
|
|
use crate::Ruma;
|
|
|
|
|
|
|
|
|
|
/// # `GET /_matrix/client/r0/rooms/{roomId}/aliases`
|
|
|
|
|
///
|
|
|
|
|
/// Lists all aliases of the room.
|
|
|
|
|
///
|
|
|
|
|
/// - Only users joined to the room are allowed to call this, or if
|
|
|
|
|
/// `history_visibility` is world readable in the room
|
|
|
|
|
pub(crate) async fn get_room_aliases_route(
|
2024-12-15 00:05:47 -05:00
|
|
|
State(services): State<crate::State>,
|
|
|
|
|
body: Ruma<aliases::v3::Request>,
|
2024-11-06 18:27:40 +00:00
|
|
|
) -> Result<aliases::v3::Response> {
|
2025-04-26 23:06:43 +00:00
|
|
|
let sender_user = body.sender_user();
|
2024-11-06 18:27:40 +00:00
|
|
|
|
|
|
|
|
if !services
|
|
|
|
|
.rooms
|
|
|
|
|
.state_accessor
|
|
|
|
|
.user_can_see_state_events(sender_user, &body.room_id)
|
|
|
|
|
.await
|
|
|
|
|
{
|
2025-04-26 23:50:03 +00:00
|
|
|
return Err!(Request(Forbidden("You don't have permission to view this room.",)));
|
2024-11-06 18:27:40 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-29 12:25:42 -04:00
|
|
|
let aliases = services
|
2026-04-07 14:40:10 +01:00
|
|
|
.rooms
|
|
|
|
|
.alias
|
|
|
|
|
.local_aliases_for_room(&body.room_id)
|
|
|
|
|
.collect()
|
|
|
|
|
.await;
|
2026-03-29 12:25:42 -04:00
|
|
|
|
|
|
|
|
Ok(aliases::v3::Response::new(aliases))
|
2024-11-06 18:27:40 +00:00
|
|
|
}
|