diff --git a/src/api/client_server/directory.rs b/src/api/client_server/directory.rs index d328e0a6..c2921d12 100644 --- a/src/api/client_server/directory.rs +++ b/src/api/client_server/directory.rs @@ -228,8 +228,13 @@ pub(crate) async fn get_public_rooms_filtered_helper( .map(|c: RoomHistoryVisibilityEventContent| { c.history_visibility == HistoryVisibility::WorldReadable }) - .map_err(|_| Error::bad_database("Invalid room history visibility event in database.")) - })?, + .map_err(|e| { + error!( + "Invalid room history visibility event in database for room {}: {e}", + &room_id + ); + Error::bad_database("Invalid room history visibility event in database.") + })})?, guest_can_join: services() .rooms .state_accessor diff --git a/src/api/client_server/room.rs b/src/api/client_server/room.rs index 9c40d865..d8fadbdc 100644 --- a/src/api/client_server/room.rs +++ b/src/api/client_server/room.rs @@ -563,12 +563,12 @@ pub async fn get_room_event_route(body: Ruma) -> Re /// /// Lists all aliases of the room. /// -/// - Only users joined to the room are allowed to call this TODO: Allow any -/// user to call it if `history_visibility` is world readable +/// - Only users joined to the room are allowed to call this, or if +/// `history_visibility` is world readable in the room pub async fn get_room_aliases_route(body: Ruma) -> Result { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); - if !services().rooms.state_cache.is_joined(sender_user, &body.room_id)? { + if !services().rooms.state_accessor.user_can_see_state_events(sender_user, &body.room_id)? { return Err(Error::BadRequest( ErrorKind::Forbidden, "You don't have permission to view this room.", diff --git a/src/service/rooms/state_accessor/mod.rs b/src/service/rooms/state_accessor/mod.rs index 0e07b012..af0ab238 100644 --- a/src/service/rooms/state_accessor/mod.rs +++ b/src/service/rooms/state_accessor/mod.rs @@ -194,7 +194,10 @@ impl Service { |s| { serde_json::from_str(s.content.get()) .map(|c: RoomHistoryVisibilityEventContent| c.history_visibility) - .map_err(|_| Error::bad_database("Invalid history visibility event in database.")) + .map_err(|e| { + error!("Invalid history visibility event in database for room {}: {e}", &room_id); + Error::bad_database("Invalid history visibility event in database.") + }) }, )?;