diff options
author | Erik Johnston <erik@matrix.org> | 2014-09-01 18:24:56 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2014-09-01 18:24:56 +0100 |
commit | b8ab9f1c0a93c2c52f2990c42e5cb27167281694 (patch) | |
tree | 039e8304e5b5994f2d94579ce7ef7a60cdad5e9c /synapse/handlers/room.py | |
parent | Merge branch 'develop' of github.com:matrix-org/synapse into room_config (diff) | |
download | synapse-b8ab9f1c0a93c2c52f2990c42e5cb27167281694.tar.xz |
Add all the necessary checks to make banning work.
Diffstat (limited to 'synapse/handlers/room.py')
-rw-r--r-- | synapse/handlers/room.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 9262afb474..f33bec9cc1 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -166,7 +166,7 @@ class RoomCreationHandler(BaseRoomHandler): power_levels_event = create( etype=RoomPowerLevelsEvent.TYPE, - **{creator.to_string(): 10} + **{creator.to_string(): 10, "default": 0} ) join_rule = JoinRules.PUBLIC if is_public else JoinRules.INVITE @@ -343,6 +343,16 @@ class RoomMemberHandler(BaseRoomHandler): if do_auth: yield self.auth.check(event, snapshot, raises=True) + # If we're banning someone, set a req power level + if event.membership == Membership.BAN: + if not hasattr(event, "required_power_level") or event.required_power_level is None: + # Add some default required_power_level + user_level = yield self.store.get_power_level( + event.room_id, + event.user_id, + ) + event.required_power_level = user_level + if prev_state and prev_state.membership == event.membership: # double same action, treat this event as a NOOP. defer.returnValue({}) |