|
6 | 6 | from __future__ import annotations |
7 | 7 |
|
8 | 8 | from typing import Any, NamedTuple |
| 9 | +import json |
9 | 10 |
|
10 | 11 | from mautrix.types import ( |
11 | 12 | Member, |
@@ -213,13 +214,13 @@ async def get_power_levels(self, room_id: RoomID) -> PowerLevelStateEventContent |
213 | 214 | return PowerLevelStateEventContent.parse_json(power_levels_json) |
214 | 215 |
|
215 | 216 | async def set_power_levels( |
216 | | - self, room_id: RoomID, content: PowerLevelStateEventContent |
| 217 | + self, room_id: RoomID, content: PowerLevelStateEventContent | dict[str, Any] |
217 | 218 | ) -> None: |
218 | 219 | await self.db.execute( |
219 | 220 | "INSERT INTO mx_room_state (room_id, power_levels) VALUES ($1, $2) " |
220 | 221 | "ON CONFLICT (room_id) DO UPDATE SET power_levels=$2", |
221 | 222 | room_id, |
222 | | - content.json(), |
| 223 | + json.dumps(content.serialize() if isinstance(content, Serializable) else content), |
223 | 224 | ) |
224 | 225 |
|
225 | 226 | async def has_encryption_info_cached(self, room_id: RoomID) -> bool: |
@@ -250,5 +251,7 @@ async def set_encryption_info( |
250 | 251 | "ON CONFLICT (room_id) DO UPDATE SET is_encrypted=true, encryption=$2" |
251 | 252 | ) |
252 | 253 | await self.db.execute( |
253 | | - q, room_id, content.json() if isinstance(content, Serializable) else content |
| 254 | + q, |
| 255 | + room_id, |
| 256 | + json.dumps(content.serialize() if isinstance(content, Serializable) else content), |
254 | 257 | ) |
0 commit comments