mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-14 11:57:44 +00:00
Check if a user is in the room before sending a PowerLevel event on their behalf (#9235)
This commit is contained in:
parent
300d0d756a
commit
2e537a0280
2 changed files with 12 additions and 1 deletions
1
changelog.d/9235.bugfix
Normal file
1
changelog.d/9235.bugfix
Normal file
|
@ -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.
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue