fix: preserve matrix room metadata when setting platform chat id

This commit is contained in:
Mikhail Putilovskij 2026-04-19 16:52:43 +03:00
parent f3f9b10d6b
commit 5782001d3d
2 changed files with 11 additions and 2 deletions

View file

@ -27,7 +27,7 @@ async def get_platform_chat_id(store: StateStore, room_id: str) -> str | None:
async def set_platform_chat_id(
store: StateStore, room_id: str, platform_chat_id: str
) -> None:
meta = await get_room_meta(store, room_id) or {}
meta = dict(await get_room_meta(store, room_id) or {})
meta["platform_chat_id"] = platform_chat_id
await set_room_meta(store, room_id, meta)

View file

@ -50,11 +50,20 @@ async def test_room_meta_roundtrip_with_platform_chat_id(store: InMemoryStore):
async def test_platform_chat_id_helpers_roundtrip(store: InMemoryStore):
meta = {
"chat_id": "C1",
"matrix_user_id": "@alice:example.org",
"display_name": "Research",
}
await set_room_meta(store, "!r:m.org", meta)
await set_platform_chat_id(store, "!r:m.org", "chat-platform-1")
assert await get_platform_chat_id(store, "!r:m.org") == "chat-platform-1"
assert await get_room_meta(store, "!r:m.org") == {
"platform_chat_id": "chat-platform-1"
"chat_id": "C1",
"matrix_user_id": "@alice:example.org",
"display_name": "Research",
"platform_chat_id": "chat-platform-1",
}