Skip to content

Commit

Permalink
Always cast power levels to int
Browse files Browse the repository at this point in the history
Synapse is broken, so there are lots of strings in power level events

Fixes mautrix/telegram#526
  • Loading branch information
tulir committed Oct 9, 2020
1 parent e7fd4ee commit 0e3fafe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mautrix/types/event/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PowerLevelStateEventContent(SerializableAttrs['PowerLevelStateEventContent
redact: int = 50

def get_user_level(self, user_id: UserID) -> int:
return self.users.get(user_id, self.users_default)
return int(self.users.get(user_id, self.users_default))

def set_user_level(self, user_id: UserID, level: int) -> None:
if level == self.users_default:
Expand All @@ -46,8 +46,8 @@ def ensure_user_level(self, user_id: UserID, level: int) -> bool:
return False

def get_event_level(self, event_type: EventType) -> int:
return self.events.get(event_type,
self.state_default if event_type.is_state else self.events_default)
return int(self.events.get(event_type, (self.state_default if event_type.is_state
else self.events_default)))

def set_event_level(self, event_type: EventType, level: int) -> None:
if level == self.state_default if event_type.is_state else self.events_default:
Expand Down

0 comments on commit 0e3fafe

Please sign in to comment.