Update room member models on power levels event

This commit is contained in:
miruka 2020-07-12 19:06:35 -04:00
parent 6ff3cc5f39
commit 9d397b62c5
2 changed files with 9 additions and 1 deletions

View File

@ -1,6 +1,5 @@
# TODO
- when promiting someone in room as admin, rank isn't updated in members list
- save and restore status in accounts.json
- mark accounts as offline when closing mirage
- document new x11 dependnecy (auto-idle)

View File

@ -315,6 +315,15 @@ class NioCallbacks:
) -> None:
self.client.power_levels_content[room.room_id] = ev.source["content"]
try:
previous_levels = ev.source["unsigned"]["prev_content"]["users"]
except KeyError:
previous_levels = {}
for user_id, level in ev.power_levels.users.items():
if user_id in room.users and level != previous_levels.get(user_id):
await self.client.add_member(room, user_id)
co = "%1 changed the room's permissions" # TODO: improve
await self.client.register_nio_event(room, ev, content=co)