Update room member models on power levels event
This commit is contained in:
parent
6ff3cc5f39
commit
9d397b62c5
1
TODO.md
1
TODO.md
|
@ -1,6 +1,5 @@
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
- when promiting someone in room as admin, rank isn't updated in members list
|
|
||||||
- save and restore status in accounts.json
|
- save and restore status in accounts.json
|
||||||
- mark accounts as offline when closing mirage
|
- mark accounts as offline when closing mirage
|
||||||
- document new x11 dependnecy (auto-idle)
|
- document new x11 dependnecy (auto-idle)
|
||||||
|
|
|
@ -315,6 +315,15 @@ class NioCallbacks:
|
||||||
) -> None:
|
) -> None:
|
||||||
self.client.power_levels_content[room.room_id] = ev.source["content"]
|
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
|
co = "%1 changed the room's permissions" # TODO: improve
|
||||||
await self.client.register_nio_event(room, ev, content=co)
|
await self.client.register_nio_event(room, ev, content=co)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user