Skip to content

Commit aacc831

Browse files
committed
Actually allow raw dicts in PgStateStore
1 parent d1e3fc5 commit aacc831

File tree

1 file changed

+6
-3
lines changed
  • mautrix/client/state_store/asyncpg

1 file changed

+6
-3
lines changed

mautrix/client/state_store/asyncpg/store.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from __future__ import annotations
77

88
from typing import Any, NamedTuple
9+
import json
910

1011
from mautrix.types import (
1112
Member,
@@ -213,13 +214,13 @@ async def get_power_levels(self, room_id: RoomID) -> PowerLevelStateEventContent
213214
return PowerLevelStateEventContent.parse_json(power_levels_json)
214215

215216
async def set_power_levels(
216-
self, room_id: RoomID, content: PowerLevelStateEventContent
217+
self, room_id: RoomID, content: PowerLevelStateEventContent | dict[str, Any]
217218
) -> None:
218219
await self.db.execute(
219220
"INSERT INTO mx_room_state (room_id, power_levels) VALUES ($1, $2) "
220221
"ON CONFLICT (room_id) DO UPDATE SET power_levels=$2",
221222
room_id,
222-
content.json(),
223+
json.dumps(content.serialize() if isinstance(content, Serializable) else content),
223224
)
224225

225226
async def has_encryption_info_cached(self, room_id: RoomID) -> bool:
@@ -250,5 +251,7 @@ async def set_encryption_info(
250251
"ON CONFLICT (room_id) DO UPDATE SET is_encrypted=true, encryption=$2"
251252
)
252253
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),
254257
)

0 commit comments

Comments
 (0)