diff --git a/src/client_server/room.rs b/src/client_server/room.rs
index 6e271308..1fcf2d6c 100644
--- a/src/client_server/room.rs
+++ b/src/client_server/room.rs
@@ -6,7 +6,7 @@ use log::info;
use ruma::{
api::client::{
error::ErrorKind,
- r0::room::{self, create_room, get_room_event, upgrade_room},
+ r0::room::{self, aliases, create_room, get_room_event, upgrade_room},
},
events::{
room::{guest_access, history_visibility, join_rules, member, name, topic},
@@ -334,6 +334,34 @@ pub async fn get_room_event_route(
.into())
}
+#[cfg_attr(
+ feature = "conduit_bin",
+ get("/_matrix/client/r0/rooms/<_>/aliases", data = "
")
+)]
+#[tracing::instrument(skip(db, body))]
+pub async fn get_room_aliases_route(
+ db: DatabaseGuard,
+ body: Ruma>,
+) -> ConduitResult {
+ let sender_user = body.sender_user.as_ref().expect("user is authenticated");
+
+ if !db.rooms.is_joined(sender_user, &body.room_id)? {
+ return Err(Error::BadRequest(
+ ErrorKind::Forbidden,
+ "You don't have permission to view this room.",
+ ));
+ }
+
+ Ok(aliases::Response {
+ aliases: db
+ .rooms
+ .room_aliases(&body.room_id)
+ .filter_map(|a| a.ok())
+ .collect(),
+ }
+ .into())
+}
+
#[cfg_attr(
feature = "conduit_bin",
post("/_matrix/client/r0/rooms/<_room_id>/upgrade", data = "")
diff --git a/src/main.rs b/src/main.rs
index f69bc48a..a5face78 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -60,6 +60,7 @@ fn setup_rocket(config: Figment, data: Arc>) -> rocket::Rocket<
client_server::set_pushrule_actions_route,
client_server::delete_pushrule_route,
client_server::get_room_event_route,
+ client_server::get_room_aliases_route,
client_server::get_filter_route,
client_server::create_filter_route,
client_server::set_global_account_data_route,