refactor guest_can_join
into 1 single function
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
016270b33b
commit
4b4c0952a2
3 changed files with 14 additions and 25 deletions
|
@ -17,7 +17,6 @@ use ruma::{
|
|||
avatar::RoomAvatarEventContent,
|
||||
canonical_alias::RoomCanonicalAliasEventContent,
|
||||
create::RoomCreateEventContent,
|
||||
guest_access::{GuestAccess, RoomGuestAccessEventContent},
|
||||
join_rules::{AllowRule, JoinRule, RoomJoinRulesEventContent, RoomMembership},
|
||||
topic::RoomTopicEventContent,
|
||||
},
|
||||
|
@ -591,7 +590,7 @@ impl Service {
|
|||
})
|
||||
.unwrap_or(None),
|
||||
world_readable: services().rooms.state_accessor.is_world_readable(room_id)?,
|
||||
guest_can_join: guest_can_join(room_id)?,
|
||||
guest_can_join: services().rooms.state_accessor.guest_can_join(room_id)?,
|
||||
avatar_url: services()
|
||||
.rooms
|
||||
.state_accessor
|
||||
|
@ -847,19 +846,6 @@ fn is_accessable_child_recurse(
|
|||
}
|
||||
}
|
||||
|
||||
/// Checks if guests are able to join a given room
|
||||
fn guest_can_join(room_id: &RoomId) -> Result<bool, Error> {
|
||||
services()
|
||||
.rooms
|
||||
.state_accessor
|
||||
.room_state_get(room_id, &StateEventType::RoomGuestAccess, "")?
|
||||
.map_or(Ok(false), |s| {
|
||||
serde_json::from_str(s.content.get())
|
||||
.map(|c: RoomGuestAccessEventContent| c.guest_access == GuestAccess::CanJoin)
|
||||
.map_err(|_| Error::bad_database("Invalid room guest access event in database."))
|
||||
})
|
||||
}
|
||||
|
||||
/// 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