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

Check if a user is in the room before sending a PowerLevel event on their behalf #9235

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -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: