Skip to content

Commit ae4ce6e

Browse files
committed
fix(room service): enable the thread subscriptions extension iff the server advertises support for it
1 parent 472b934 commit ae4ce6e

File tree

1 file changed

+23
-8
lines changed
  • crates/matrix-sdk-ui/src/room_list_service

1 file changed

+23
-8
lines changed

crates/matrix-sdk-ui/src/room_list_service/mod.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,14 @@ use matrix_sdk::{
6767
};
6868
pub use room_list::*;
6969
use ruma::{
70-
OwnedRoomId, RoomId, UInt, api::client::sync::sync_events::v5 as http, assign,
70+
OwnedRoomId, RoomId, UInt,
71+
api::{FeatureFlag, client::sync::sync_events::v5 as http},
72+
assign,
7173
events::StateEventType,
7274
};
7375
pub use state::*;
7476
use thiserror::Error;
75-
use tracing::{debug, error};
77+
use tracing::{debug, error, warn};
7678

7779
/// The default `required_state` constant value for sliding sync lists and
7880
/// sliding sync room subscriptions.
@@ -156,12 +158,25 @@ impl RoomListService {
156158
}));
157159

158160
if client.enabled_thread_subscriptions() {
159-
builder = builder.with_thread_subscriptions_extension(
160-
assign!(http::request::ThreadSubscriptions::default(), {
161-
enabled: Some(true),
162-
limit: Some(ruma::uint!(10))
163-
}),
164-
);
161+
let server_features = client
162+
.supported_versions()
163+
.await
164+
.map_err(|err| Error::SlidingSync(err.into()))?
165+
.features;
166+
167+
if !server_features.contains(&FeatureFlag::from("org.matrix.msc4306")) {
168+
warn!(
169+
"Thread subscriptions extension is requested on the client, but the server doesn't advertise support for it: not enabling."
170+
);
171+
} else {
172+
debug!("Enabling the thread subscriptions extension");
173+
builder = builder.with_thread_subscriptions_extension(
174+
assign!(http::request::ThreadSubscriptions::default(), {
175+
enabled: Some(true),
176+
limit: Some(ruma::uint!(10))
177+
}),
178+
);
179+
}
165180
}
166181

167182
if share_pos {

0 commit comments

Comments
 (0)