summary refs log tree commit diff
path: root/synapse/event_auth.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-07-02 11:39:28 +0100
committerErik Johnston <erik@matrix.org>2018-07-02 11:40:32 +0100
commit2c33b55738d54186d7655972a6707336b2168534 (patch)
tree6ba031ecc51b7802d83ec314492dfc4eb64be470 /synapse/event_auth.py
parentEnsure that we define sender_domain (diff)
downloadsynapse-2c33b55738d54186d7655972a6707336b2168534.tar.xz
Avoid relying on int vs None comparison
Python 3 doesn't support comparing None to ints
Diffstat (limited to 'synapse/event_auth.py')
-rw-r--r--synapse/event_auth.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/synapse/event_auth.py b/synapse/event_auth.py
index 9fc8b34346..cdf99fd140 100644
--- a/synapse/event_auth.py
+++ b/synapse/event_auth.py
@@ -525,7 +525,11 @@ def _check_power_levels(event, auth_events):
                     "to your own"
                 )
 
-        if old_level > user_level or new_level > user_level:
+        # Check if the old and new levels are greater than the user level
+        # (if defined)
+        old_level_too_big = old_level is not None and old_level > user_level
+        new_level_too_big = new_level is not None and new_level > user_level
+        if old_level_too_big or new_level_too_big:
             raise AuthError(
                 403,
                 "You don't have permission to add ops level greater "