fix(matrix): reconcile pending invites from sync state

This commit is contained in:
Charles Brooks
2026-04-13 20:02:07 -04:00
committed by Teknium
parent 6649e7e746
commit 57f8cf00e9
2 changed files with 58 additions and 0 deletions

View File

@@ -1204,6 +1204,40 @@ class TestMatrixSyncLoop:
fake_client.handle_sync.assert_called_once()
mock_sync_store.put_next_batch.assert_awaited_once_with("s1234")
@pytest.mark.asyncio
async def test_sync_loop_reconciles_pending_invites(self):
"""Pending rooms.invite entries should be joined if callbacks were missed."""
adapter = _make_adapter()
adapter._closing = False
async def _sync_once(**kwargs):
adapter._closing = True
return {
"rooms": {
"join": {"!joined:example.org": {}},
"invite": {"!invited:example.org": {}},
},
"next_batch": "s1234",
}
mock_sync_store = MagicMock()
mock_sync_store.get_next_batch = AsyncMock(return_value=None)
mock_sync_store.put_next_batch = AsyncMock()
fake_client = MagicMock()
fake_client.sync = AsyncMock(side_effect=_sync_once)
fake_client.join_room = AsyncMock()
fake_client.sync_store = mock_sync_store
fake_client.handle_sync = MagicMock(return_value=[])
adapter._client = fake_client
with patch.object(adapter, "_refresh_dm_cache", AsyncMock()):
await adapter._sync_loop()
fake_client.join_room.assert_awaited_once()
assert "!joined:example.org" in adapter._joined_rooms
assert "!invited:example.org" in adapter._joined_rooms
class TestMatrixUploadAndSend:
@pytest.mark.asyncio