|
5 | 5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
6 | 6 | from __future__ import annotations |
7 | 7 |
|
8 | | -from typing import NamedTuple |
| 8 | +from typing import Any, NamedTuple |
9 | 9 |
|
10 | 10 | from mautrix.types import ( |
11 | 11 | Member, |
|
14 | 14 | PowerLevelStateEventContent, |
15 | 15 | RoomEncryptionStateEventContent, |
16 | 16 | RoomID, |
| 17 | + Serializable, |
17 | 18 | UserID, |
18 | 19 | ) |
19 | 20 | from mautrix.util.async_db import Database, Scheme |
@@ -242,10 +243,12 @@ async def get_encryption_info(self, room_id: RoomID) -> RoomEncryptionStateEvent |
242 | 243 | return RoomEncryptionStateEventContent.parse_json(row["encryption"]) |
243 | 244 |
|
244 | 245 | async def set_encryption_info( |
245 | | - self, room_id: RoomID, content: RoomEncryptionStateEventContent |
| 246 | + self, room_id: RoomID, content: RoomEncryptionStateEventContent | dict[str, Any] |
246 | 247 | ) -> None: |
247 | 248 | q = ( |
248 | 249 | "INSERT INTO mx_room_state (room_id, is_encrypted, encryption) VALUES ($1, true, $2) " |
249 | 250 | "ON CONFLICT (room_id) DO UPDATE SET is_encrypted=true, encryption=$2" |
250 | 251 | ) |
251 | | - await self.db.execute(q, room_id, content.json()) |
| 252 | + await self.db.execute( |
| 253 | + q, room_id, content.json() if isinstance(content, Serializable) else content |
| 254 | + ) |
0 commit comments