mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-11-17 10:48:18 -07:00
Implement getting room aliases
Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
This commit is contained in:
parent
f43fd6a475
commit
0d33cc4acd
@ -6,7 +6,7 @@ use log::info;
|
|||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::room::{self, create_room, get_room_event, upgrade_room},
|
r0::room::{self, aliases, create_room, get_room_event, upgrade_room},
|
||||||
},
|
},
|
||||||
events::{
|
events::{
|
||||||
room::{guest_access, history_visibility, join_rules, member, name, topic},
|
room::{guest_access, history_visibility, join_rules, member, name, topic},
|
||||||
@ -334,6 +334,34 @@ pub async fn get_room_event_route(
|
|||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/rooms/<_>/aliases", data = "<body>")
|
||||||
|
)]
|
||||||
|
#[tracing::instrument(skip(db, body))]
|
||||||
|
pub async fn get_room_aliases_route(
|
||||||
|
db: DatabaseGuard,
|
||||||
|
body: Ruma<aliases::Request<'_>>,
|
||||||
|
) -> ConduitResult<aliases::Response> {
|
||||||
|
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(
|
#[cfg_attr(
|
||||||
feature = "conduit_bin",
|
feature = "conduit_bin",
|
||||||
post("/_matrix/client/r0/rooms/<_room_id>/upgrade", data = "<body>")
|
post("/_matrix/client/r0/rooms/<_room_id>/upgrade", data = "<body>")
|
||||||
|
@ -60,6 +60,7 @@ fn setup_rocket(config: Figment, data: Arc<RwLock<Database>>) -> rocket::Rocket<
|
|||||||
client_server::set_pushrule_actions_route,
|
client_server::set_pushrule_actions_route,
|
||||||
client_server::delete_pushrule_route,
|
client_server::delete_pushrule_route,
|
||||||
client_server::get_room_event_route,
|
client_server::get_room_event_route,
|
||||||
|
client_server::get_room_aliases_route,
|
||||||
client_server::get_filter_route,
|
client_server::get_filter_route,
|
||||||
client_server::create_filter_route,
|
client_server::create_filter_route,
|
||||||
client_server::set_global_account_data_route,
|
client_server::set_global_account_data_route,
|
||||||
|
Loading…
Reference in New Issue
Block a user