fix(ui): Don't do a authenticated /versions call when building the roomlist service

This commit is contained in:
Damir Jelić
2025-11-11 12:58:37 +01:00
parent 9a3857d3a7
commit f61ba4f47c
2 changed files with 26 additions and 6 deletions

View File

@@ -63,7 +63,7 @@ use eyeball::Subscriber;
use futures_util::{Stream, StreamExt, pin_mut};
use matrix_sdk::{
Client, Error as SlidingSyncError, Room, SlidingSync, SlidingSyncList, SlidingSyncMode,
event_cache::EventCacheError, timeout::timeout,
config::RequestConfig, event_cache::EventCacheError, timeout::timeout,
};
pub use room_list::*;
use ruma::{
@@ -158,11 +158,26 @@ impl RoomListService {
}));
if client.enabled_thread_subscriptions() {
let server_features = client
.supported_versions()
let server_features = if let Some(cached) = client
.supported_versions_cached()
.await
.map_err(|err| Error::SlidingSync(err.into()))?
.features;
.map_err(|e| Error::SlidingSync(e.into()))?
{
cached.features
} else {
// Our `/versions` calls don't support token refresh as of now (11.11.2025), so
// we're going to skip the sending of the authentication headers in case they
// might have expired.
//
// We only care about a feature which is advertised without being authenticaded
// anyways.
client
.fetch_server_versions(Some(RequestConfig::new().skip_auth()))
.await
.map_err(|e| Error::SlidingSync(e.into()))?
.as_supported_versions()
.features
};
if !server_features.contains(&FeatureFlag::from("org.matrix.msc4306")) {
warn!(

View File

@@ -2906,7 +2906,12 @@ async fn test_thread_subscriptions_extension_enabled_only_if_server_advertises_i
.mock_versions()
.ok_custom(&["v1.11"], &features_map)
.named("/versions, first time")
.mock_once()
// This used to be a `mock_once()`, but we're not caching the versions in the
// `RoomListService::new()` method anymore, so we're now doing a couple more requests
// for this. The sync will want to know about the `/versions` once it tries to build
// the request path.
.up_to_n_times(3)
.expect(3..)
.mount()
.await;