diff options
author | Erik Johnston <erik@matrix.org> | 2014-09-23 17:36:17 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2014-09-23 17:36:24 +0100 |
commit | bc250a6afa68b7584f3b7b3aacb919df406da75a (patch) | |
tree | db6bfd1b559eadcb70e742f5df0b4531d6ed17ff /synapse/storage/room.py | |
parent | Add prune_event method (diff) | |
download | synapse-bc250a6afa68b7584f3b7b3aacb919df406da75a.tar.xz |
SYN-12: Implement auth for deletion by adding a 'delete_level' on the ops levels event
SYN-12 # comment Auth has been added.
Diffstat (limited to 'synapse/storage/room.py')
-rw-r--r-- | synapse/storage/room.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/synapse/storage/room.py b/synapse/storage/room.py index 5adf8cdf1b..b1239a0f1a 100644 --- a/synapse/storage/room.py +++ b/synapse/storage/room.py @@ -27,7 +27,7 @@ import logging logger = logging.getLogger(__name__) -OpsLevel = collections.namedtuple("OpsLevel", ("ban_level", "kick_level")) +OpsLevel = collections.namedtuple("OpsLevel", ("ban_level", "kick_level", "delete_level")) class RoomStore(SQLBaseStore): @@ -189,7 +189,8 @@ class RoomStore(SQLBaseStore): def _get_ops_levels(self, txn, room_id): sql = ( - "SELECT ban_level, kick_level FROM room_ops_levels as r " + "SELECT ban_level, kick_level, delete_level " + "FROM room_ops_levels as r " "INNER JOIN current_state_events as c " "ON r.event_id = c.event_id " "WHERE c.room_id = ? " @@ -198,7 +199,7 @@ class RoomStore(SQLBaseStore): rows = txn.execute(sql, (room_id,)).fetchall() if len(rows) == 1: - return OpsLevel(rows[0][0], rows[0][1]) + return OpsLevel(rows[0][0], rows[0][1], rows[0][2]) else: return OpsLevel(None, None) @@ -326,6 +327,9 @@ class RoomStore(SQLBaseStore): if "ban_level" in event.content: content["ban_level"] = event.content["ban_level"] + if "delete_level" in event.content: + content["delete_level"] = event.content["delete_level"] + self._simple_insert_txn( txn, "room_ops_levels", |