use map_or in user_can_invite
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
ddcf43f1b8
commit
b9e442b694
1 changed files with 1 additions and 2 deletions
|
@ -143,12 +143,11 @@ impl Service {
|
|||
/// Whether a user's power level is sufficient to invite other users
|
||||
pub fn user_can_invite(&self, user_id: &UserId, room_id: &RoomId) -> Result<bool> {
|
||||
self.room_state_get(room_id, &StateEventType::RoomPowerLevels, "")?
|
||||
.map(|pdu_event| {
|
||||
.map_or(Ok(false), |pdu_event| {
|
||||
serde_json::from_str(pdu_event.content.get()).map(|content: RoomPowerLevelsEventContent| {
|
||||
content.users.get(user_id).unwrap_or(&content.users_default) >= &content.invite
|
||||
})
|
||||
})
|
||||
.unwrap_or(Ok(false))
|
||||
.map_err(|_| Error::bad_database("Invalid history visibility event in database."))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue