diff --git a/bindings/matrix-sdk-ffi/changelog.d/6726.feature.md b/bindings/matrix-sdk-ffi/changelog.d/6726.feature.md new file mode 100644 index 00000000000..f2a131ac708 --- /dev/null +++ b/bindings/matrix-sdk-ffi/changelog.d/6726.feature.md @@ -0,0 +1 @@ +Add `SyncServiceBuilder::with_profiles_extension` to enable the Profiles sliding sync extension, which syncs global profile fields such as `m.status` and `m.call`. diff --git a/bindings/matrix-sdk-ffi/src/sync_service.rs b/bindings/matrix-sdk-ffi/src/sync_service.rs index 8cb3bc0d768..bf0d443e90e 100644 --- a/bindings/matrix-sdk-ffi/src/sync_service.rs +++ b/bindings/matrix-sdk-ffi/src/sync_service.rs @@ -128,6 +128,16 @@ impl SyncServiceBuilder { Arc::new(Self { builder, ..this }) } + /// Enable the Profiles sliding sync extension for the room list service. + /// + /// Required to merge the global `m.status` and `m.call` fields into the + /// room members and profiles read from the SDK. + pub fn with_profiles_extension(self: Arc) -> Arc { + let this = unwrap_or_clone_arc(self); + let builder = this.builder.with_profiles_extension(); + Arc::new(Self { builder, ..this }) + } + /// Set a custom Sliding Sync connection ID for the room list service. /// /// By default [`matrix_sdk_ui::room_list_service::DEFAULT_CONNECTION_ID`] diff --git a/crates/matrix-sdk-ui/changelog.d/6726.added.md b/crates/matrix-sdk-ui/changelog.d/6726.added.md new file mode 100644 index 00000000000..f2a131ac708 --- /dev/null +++ b/crates/matrix-sdk-ui/changelog.d/6726.added.md @@ -0,0 +1 @@ +Add `SyncServiceBuilder::with_profiles_extension` to enable the Profiles sliding sync extension, which syncs global profile fields such as `m.status` and `m.call`. diff --git a/crates/matrix-sdk-ui/src/room_list_service/mod.rs b/crates/matrix-sdk-ui/src/room_list_service/mod.rs index a0143d83fe6..4e7257a0dbb 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/mod.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/mod.rs @@ -141,7 +141,8 @@ impl RoomListService { /// to create one in this case using /// [`EncryptionSyncService`][crate::encryption_sync_service::EncryptionSyncService]. pub async fn new(client: Client) -> Result { - Self::new_with(client, true, DEFAULT_CONNECTION_ID, DEFAULT_LIST_TIMELINE_LIMIT).await + Self::new_with(client, true, DEFAULT_CONNECTION_ID, DEFAULT_LIST_TIMELINE_LIMIT, false) + .await } /// Like [`RoomListService::new`] but with additional configuration options. @@ -150,6 +151,9 @@ impl RoomListService { /// cross-process position sharing. /// - `connection_id`: the Sliding Sync connection ID /// - `timeline_limit`: the timeline limit + /// - `profiles_extension`: enables the Profiles extension, required to + /// merge the global `m.status` and `m.call` fields into room members and + /// profiles /// /// [`SlidingSyncBuilder::share_pos`]: matrix_sdk::sliding_sync::SlidingSyncBuilder::share_pos pub async fn new_with( @@ -157,6 +161,7 @@ impl RoomListService { share_pos: bool, connection_id: &str, timeline_limit: u32, + profiles_extension: bool, ) -> Result { let mut builder = client .sliding_sync(connection_id) @@ -198,6 +203,14 @@ impl RoomListService { } } + if profiles_extension { + debug!("Enabling the profiles extension for the room list sliding sync"); + builder = builder.with_profiles_extension(assign!( + http::request::Profiles::default(), + { enabled: Some(true) } + )); + } + if share_pos { // The e2ee extensions aren't enabled in this sliding sync instance, and this is // the only one that could be used from a different process. So it's diff --git a/crates/matrix-sdk-ui/src/sync_service.rs b/crates/matrix-sdk-ui/src/sync_service.rs index 971fb6db6c9..1c712133279 100644 --- a/crates/matrix-sdk-ui/src/sync_service.rs +++ b/crates/matrix-sdk-ui/src/sync_service.rs @@ -775,6 +775,13 @@ pub struct SyncServiceBuilder { /// [`SlidingSyncBuilder::share_pos`]: matrix_sdk::sliding_sync::SlidingSyncBuilder::share_pos with_share_pos: bool, + /// Whether to enable the Profiles sliding sync extension for the room list + /// service. + /// + /// Required to merge the global `m.status` and `m.call` fields into the + /// room members and profiles read from this crate. + with_profiles_extension: bool, + /// Custom connection ID for the room list service. /// Defaults to [`room_list_service::DEFAULT_CONNECTION_ID`]. Use a /// different value for secondary processes such as iOS share extensions @@ -799,6 +806,7 @@ impl SyncServiceBuilder { client, with_offline_mode: false, with_share_pos: true, + with_profiles_extension: false, room_list_conn_id: DEFAULT_CONNECTION_ID.to_owned(), room_list_timeline_limit: DEFAULT_LIST_TIMELINE_LIMIT, parent_span: Span::none(), @@ -822,6 +830,15 @@ impl SyncServiceBuilder { self } + /// Enable the Profiles sliding sync extension for the room list service. + /// + /// Required to merge the global `m.status` and `m.call` fields into the + /// room members and profiles read from this crate. + pub fn with_profiles_extension(mut self) -> Self { + self.with_profiles_extension = true; + self + } + /// Set a custom conn_id for the room list sliding sync connection. pub fn with_room_list_conn_id(mut self, conn_id: String) -> Self { self.room_list_conn_id = conn_id; @@ -851,6 +868,7 @@ impl SyncServiceBuilder { client, with_offline_mode, with_share_pos, + with_profiles_extension, room_list_conn_id, room_list_timeline_limit, parent_span, @@ -863,6 +881,7 @@ impl SyncServiceBuilder { with_share_pos, &room_list_conn_id, room_list_timeline_limit, + with_profiles_extension, ) .await?;