summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2021-02-16 08:31:39 -0500
committerGitHub <noreply@github.com>2021-02-16 08:31:39 -0500
commit731e08c63a37f5409e0163cb3daf9cb98de38daf (patch)
treeb541cb827b28614ac57efd05b3cea53f6ff306a2 /synapse
parentDocument that pusher instances are shardable (#9407) (diff)
downloadsynapse-731e08c63a37f5409e0163cb3daf9cb98de38daf.tar.xz
Handle missing data in power levels events during room upgrade. (#9395)
Diffstat (limited to '')
-rw-r--r--synapse/handlers/room.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index 3cf6635821..591a82f459 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -425,17 +425,20 @@ class RoomCreationHandler(BaseHandler):
 
         # Copy over user power levels now as this will not be possible with >100PL users once
         # the room has been created
-
         # Calculate the minimum power level needed to clone the room
         event_power_levels = power_levels.get("events", {})
-        state_default = power_levels.get("state_default", 0)
-        ban = power_levels.get("ban")
+        state_default = power_levels.get("state_default", 50)
+        ban = power_levels.get("ban", 50)
         needed_power_level = max(state_default, ban, max(event_power_levels.values()))
 
+        # Get the user's current power level, this matches the logic in get_user_power_level,
+        # but without the entire state map.
+        user_power_levels = power_levels.setdefault("users", {})
+        users_default = power_levels.get("users_default", 0)
+        current_power_level = user_power_levels.get(user_id, users_default)
         # Raise the requester's power level in the new room if necessary
-        current_power_level = power_levels["users"][user_id]
         if current_power_level < needed_power_level:
-            power_levels["users"][user_id] = needed_power_level
+            user_power_levels[user_id] = needed_power_level
 
         await self._send_events_for_new_room(
             requester,