From b7df79e65d14b90d9faedcbbf0f56369ed87ef81 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Thu, 28 Apr 2022 22:28:39 -0400 Subject: [PATCH] Copy PL state events with evolve --- matrix_appservice_kakaotalk/portal.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/matrix_appservice_kakaotalk/portal.py b/matrix_appservice_kakaotalk/portal.py index 0d74e0a..5364535 100644 --- a/matrix_appservice_kakaotalk/portal.py +++ b/matrix_appservice_kakaotalk/portal.py @@ -33,7 +33,7 @@ import asyncio import re import time -from attr import dataclass +from attr import dataclass, evolve from mautrix.appservice import IntentAPI from mautrix.bridge import BasePortal, NotificationDisabler, async_getter_lock @@ -420,7 +420,7 @@ class Portal(DBPortal, BasePortal): sender_intent = sender.intent_for(self) if sender else self.main_intent admin_level = orig_power_levels.get_user_level(sender_intent.mxid) demoter_ids: list[UserID] = [] - power_levels = PowerLevelStateEventContent(**orig_power_levels.serialize()) + power_levels = evolve(orig_power_levels) for user_id, new_level in user_power_levels.items(): curr_level = orig_power_levels.get_user_level(user_id) if curr_level < admin_level or user_id == sender_intent.mxid: @@ -436,7 +436,7 @@ class Portal(DBPortal, BasePortal): except: self.log.exception("Failed to set power level") if demoter_ids: - power_levels = PowerLevelStateEventContent(**orig_power_levels.serialize()) + power_levels = evolve(orig_power_levels) for demoter_id in demoter_ids: power_levels.set_user_level(demoter_id, user_power_levels[demoter_id]) try: