add is_world_readable
state_accessor func, use self
instead of services()
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
1cc7cf54a7
commit
bfbb29dded
3 changed files with 25 additions and 50 deletions
|
@ -18,7 +18,6 @@ use ruma::{
|
|||
canonical_alias::RoomCanonicalAliasEventContent,
|
||||
create::RoomCreateEventContent,
|
||||
guest_access::{GuestAccess, RoomGuestAccessEventContent},
|
||||
history_visibility::{HistoryVisibility, RoomHistoryVisibilityEventContent},
|
||||
join_rules::{AllowRule, JoinRule, RoomJoinRulesEventContent, RoomMembership},
|
||||
topic::RoomTopicEventContent,
|
||||
},
|
||||
|
@ -591,7 +590,7 @@ impl Service {
|
|||
})
|
||||
})
|
||||
.unwrap_or(None),
|
||||
world_readable: world_readable(room_id)?,
|
||||
world_readable: services().rooms.state_accessor.is_world_readable(room_id)?,
|
||||
guest_can_join: guest_can_join(room_id)?,
|
||||
avatar_url: services()
|
||||
.rooms
|
||||
|
@ -858,26 +857,6 @@ fn guest_can_join(room_id: &RoomId) -> Result<bool, Error> {
|
|||
})
|
||||
}
|
||||
|
||||
/// Checks if guests are able to view room content without joining
|
||||
fn world_readable(room_id: &RoomId) -> Result<bool, Error> {
|
||||
Ok(services()
|
||||
.rooms
|
||||
.state_accessor
|
||||
.room_state_get(room_id, &StateEventType::RoomHistoryVisibility, "")?
|
||||
.map_or(Ok(false), |s| {
|
||||
serde_json::from_str(s.content.get())
|
||||
.map(|c: RoomHistoryVisibilityEventContent| c.history_visibility == HistoryVisibility::WorldReadable)
|
||||
.map_err(|e| {
|
||||
error!(
|
||||
"Invalid room history visibility event in database for room {room_id}, assuming is \
|
||||
\"shared\": {e} "
|
||||
);
|
||||
Error::bad_database("Invalid room history visibility event in database.")
|
||||
})
|
||||
})
|
||||
.unwrap_or(false))
|
||||
}
|
||||
|
||||
/// Returns the join rule for a given room
|
||||
fn get_join_rule(current_room: &RoomId) -> Result<(SpaceRoomJoinRule, Vec<OwnedRoomId>), Error> {
|
||||
Ok(services()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue