From 5782001d3dcb320298a2e3581a4d5a9085588256 Mon Sep 17 00:00:00 2001 From: Mikhail Putilovskij Date: Sun, 19 Apr 2026 16:52:43 +0300 Subject: [PATCH] fix: preserve matrix room metadata when setting platform chat id --- adapter/matrix/store.py | 2 +- tests/adapter/matrix/test_store.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/adapter/matrix/store.py b/adapter/matrix/store.py index 34532a6..5ebb61a 100644 --- a/adapter/matrix/store.py +++ b/adapter/matrix/store.py @@ -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) diff --git a/tests/adapter/matrix/test_store.py b/tests/adapter/matrix/test_store.py index 6be84c4..9fcd2a2 100644 --- a/tests/adapter/matrix/test_store.py +++ b/tests/adapter/matrix/test_store.py @@ -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", }