Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Check if a user is in the room before sending a PowerLevel event on t…
Browse files Browse the repository at this point in the history
…heir behalf (#9235)
  • Loading branch information
y-pankaj authored Jan 27, 2021
1 parent 300d0d7 commit 2e537a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/9235.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug in the `make_room_admin` admin API where it failed if the admin with the greatest power level was not in the room. Contributed by Pankaj Yadav.
12 changes: 11 additions & 1 deletion synapse/rest/admin/rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,17 @@ async def on_POST(self, request, room_identifier):
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:
Expand Down

0 comments on commit 2e537a0

Please sign in to comment.