From 4b8244fbf85df081e3abfa7a8e8754b66d671f49 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 2 Sep 2014 12:11:52 +0100 Subject: [PATCH] Fix bug where we didn't correctly store the ops power levels event. --- synapse/api/auth.py | 5 +++++ synapse/storage/__init__.py | 3 +++ synapse/storage/room.py | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/synapse/api/auth.py b/synapse/api/auth.py index e9e3279b9..54ecbe5b3 100644 --- a/synapse/api/auth.py +++ b/synapse/api/auth.py @@ -169,6 +169,11 @@ class Auth(object): ) _, kick_level = yield self.store.get_ops_levels(event.room_id) + if kick_level: + kick_level = int(kick_level) + else: + kick_level = 5 + if user_level < kick_level: raise AuthError( 403, "You cannot kick user %s." % target_user_id diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py index 7a441391f..aadaab06e 100644 --- a/synapse/storage/__init__.py +++ b/synapse/storage/__init__.py @@ -23,6 +23,7 @@ from synapse.api.events.room import ( RoomPowerLevelsEvent, RoomAddStateLevelEvent, RoomSendEventLevelEvent, + RoomOpsPowerLevelsEvent, ) from synapse.util.logutils import log_function @@ -140,6 +141,8 @@ class DataStore(RoomMemberStore, RoomStore, self._store_add_state_level(txn, event) elif event.type == RoomSendEventLevelEvent.TYPE: self._store_send_event_level(txn, event) + elif event.type == RoomOpsPowerLevelsEvent.TYPE: + self._store_ops_level(txn, event) vals = { "topological_ordering": event.depth, diff --git a/synapse/storage/room.py b/synapse/storage/room.py index 3ca07f435..01ae19031 100644 --- a/synapse/storage/room.py +++ b/synapse/storage/room.py @@ -328,7 +328,7 @@ class RoomStore(SQLBaseStore): self._simple_insert_txn( txn, - "room_send_event_levels", + "room_ops_levels", content, )