@@ -67,12 +67,14 @@ use matrix_sdk::{
6767} ;
6868pub use room_list:: * ;
6969use 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} ;
7375pub use state:: * ;
7476use 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