From 8efc91b02b07ece536628e1c4b0f4ea8fa24a6df Mon Sep 17 00:00:00 2001 From: Mikhail Putilovskij Date: Wed, 8 Apr 2026 02:18:11 +0300 Subject: [PATCH] fix(matrix): accept repeat invites before provisioning --- adapter/matrix/handlers/auth.py | 4 ++-- tests/adapter/matrix/test_dispatcher.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/adapter/matrix/handlers/auth.py b/adapter/matrix/handlers/auth.py index 83f1ac6..6882404 100644 --- a/adapter/matrix/handlers/auth.py +++ b/adapter/matrix/handlers/auth.py @@ -20,12 +20,12 @@ async def handle_invite(client: Any, room: Any, event: Any, platform, store, aut matrix_user_id = getattr(event, "sender", "") display_name = getattr(room, "display_name", None) or matrix_user_id + await client.join(room.room_id) + existing = await get_user_meta(store, matrix_user_id) if existing and existing.get("space_id"): return - await client.join(room.room_id) - user = await platform.get_or_create_user( external_id=matrix_user_id, platform="matrix", diff --git a/tests/adapter/matrix/test_dispatcher.py b/tests/adapter/matrix/test_dispatcher.py index 7f064f2..ad4746c 100644 --- a/tests/adapter/matrix/test_dispatcher.py +++ b/tests/adapter/matrix/test_dispatcher.py @@ -179,7 +179,9 @@ async def test_invite_event_is_idempotent_per_user(): runtime.chat_mgr, ) + assert client.join.await_count == 2 assert client.room_create.await_count == 2 + client.room_send.assert_awaited_once() async def test_bot_ignores_its_own_messages():