Copy PL state events with evolve
This commit is contained in:
parent
780dbed7c2
commit
b7df79e65d
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user