summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorPankaj Yadav <42418662+y-pankaj@users.noreply.github.com>2021-01-27 23:08:08 +0530
committerGitHub <noreply@github.com>2021-01-27 17:38:08 +0000
commit2e537a02804af47862b8c7e0454ae85fde616f2d (patch)
tree9a5bcc55143c57b23220386c2c3e8c1e0ff9c13b /synapse
parentMerge branch 'social_login' into develop (diff)
downloadsynapse-2e537a02804af47862b8c7e0454ae85fde616f2d.tar.xz
Check if a user is in the room before sending a PowerLevel event on their behalf (#9235)
Diffstat (limited to 'synapse')
-rw-r--r--synapse/rest/admin/rooms.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/synapse/rest/admin/rooms.py b/synapse/rest/admin/rooms.py
index da1499cab3..f14915d47e 100644
--- a/synapse/rest/admin/rooms.py
+++ b/synapse/rest/admin/rooms.py
@@ -431,7 +431,17 @@ class MakeRoomAdminRestServlet(RestServlet):
             if not admin_users:
                 raise SynapseError(400, "No local admin user in room")
 
-            admin_user_id = admin_users[-1]
+            admin_user_id = None
+
+            for admin_user in reversed(admin_users):
+                if room_state.get((EventTypes.Member, admin_user)):
+                    admin_user_id = admin_user
+                    break
+
+            if not admin_user_id:
+                raise SynapseError(
+                    400, "No local admin user in room",
+                )
 
             pl_content = power_levels.content
         else: