From 9d397b62c57954f20d349ca233ec267255eef258 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 12 Jul 2020 19:06:35 -0400 Subject: [PATCH] Update room member models on power levels event --- TODO.md | 1 - src/backend/nio_callbacks.py | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index 3b687cdf..1b1b2247 100644 --- a/TODO.md +++ b/TODO.md @@ -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) diff --git a/src/backend/nio_callbacks.py b/src/backend/nio_callbacks.py index 1ae0cc46..cd5c4662 100644 --- a/src/backend/nio_callbacks.py +++ b/src/backend/nio_callbacks.py @@ -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)