fix: preserve matrix room metadata when setting platform chat id
This commit is contained in:
parent
f3f9b10d6b
commit
5782001d3d
2 changed files with 11 additions and 2 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue