From e507eaabf60ce2b9d361028524428f87249a0730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Tue, 21 Apr 2026 09:48:45 +0200 Subject: [PATCH] feat(ffi): Expose `ffi::NotificationRoomInfo::service_members` This is needed in some clients to know if a direct room is a DM or not --- bindings/matrix-sdk-ffi/CHANGELOG.md | 3 +++ bindings/matrix-sdk-ffi/src/client.rs | 6 ++++++ bindings/matrix-sdk-ffi/src/notification.rs | 2 ++ crates/matrix-sdk-ui/src/notification_client.rs | 10 ++++++++++ 4 files changed, 21 insertions(+) diff --git a/bindings/matrix-sdk-ffi/CHANGELOG.md b/bindings/matrix-sdk-ffi/CHANGELOG.md index fca15c3ba..c7c0fff73 100644 --- a/bindings/matrix-sdk-ffi/CHANGELOG.md +++ b/bindings/matrix-sdk-ffi/CHANGELOG.md @@ -44,6 +44,9 @@ All notable changes to this project will be documented in this file. ### Features +- Expose `ffi::NotificationRoomInfo::service_members` so clients can use the list of service + members to calculate if a room is a DM from the notification info. + ([#6474](https://github.com/matrix-org/matrix-rust-sdk/pull/6474)) - Enable `experimental-push-secrets` feature by default. ([#6473](https://github.com/matrix-org/matrix-rust-sdk/pull/6394)) - Add new high-level search helpers `RoomSearchIterator` and `GlobalSearchIterator` to perform diff --git a/bindings/matrix-sdk-ffi/src/client.rs b/bindings/matrix-sdk-ffi/src/client.rs index f4a789dd8..902fb938c 100644 --- a/bindings/matrix-sdk-ffi/src/client.rs +++ b/bindings/matrix-sdk-ffi/src/client.rs @@ -2174,6 +2174,12 @@ async fn notification_handler( topic: room.topic(), join_rule: room.join_rule().map(TryInto::try_into).transpose().ok().flatten(), joined_members_count: room.joined_members_count(), + service_members: room + .service_members() + .unwrap_or_default() + .iter() + .map(ToString::to_string) + .collect(), is_encrypted: Some(room.encryption_state().is_encrypted()), is_direct, is_space: room.is_space(), diff --git a/bindings/matrix-sdk-ffi/src/notification.rs b/bindings/matrix-sdk-ffi/src/notification.rs index e53f00af6..cd3c28112 100644 --- a/bindings/matrix-sdk-ffi/src/notification.rs +++ b/bindings/matrix-sdk-ffi/src/notification.rs @@ -49,6 +49,7 @@ pub struct NotificationRoomInfo { pub topic: Option, pub join_rule: Option, pub joined_members_count: u64, + pub service_members: Vec, pub is_encrypted: Option, pub is_direct: bool, pub is_space: bool, @@ -106,6 +107,7 @@ impl NotificationItem { topic: item.room_topic, join_rule: item.room_join_rule.map(TryInto::try_into).transpose().ok().flatten(), joined_members_count: item.joined_members_count, + service_members: item.service_members, is_encrypted: item.is_room_encrypted, is_direct: item.is_direct_message_room, is_space: item.is_space, diff --git a/crates/matrix-sdk-ui/src/notification_client.rs b/crates/matrix-sdk-ui/src/notification_client.rs index 67142f6ac..a375eb406 100644 --- a/crates/matrix-sdk-ui/src/notification_client.rs +++ b/crates/matrix-sdk-ui/src/notification_client.rs @@ -20,6 +20,7 @@ use std::{ }; use futures_util::{StreamExt as _, pin_mut}; +use itertools::Itertools; use matrix_sdk::{ Client, ClientBuildError, SlidingSyncList, SlidingSyncMode, room::Room, sleep::sleep, }; @@ -938,6 +939,8 @@ pub struct NotificationItem { pub is_direct_message_room: bool, /// Numbers of members who joined the room. pub joined_members_count: u64, + /// Number of service members in the room. + pub service_members: Vec, /// Is the room a space? pub is_space: bool, @@ -1022,6 +1025,12 @@ impl NotificationItem { let is_noisy = push_actions.map(|actions| actions.iter().any(|a| a.sound().is_some())); let has_mention = push_actions.map(|actions| actions.iter().any(|a| a.is_highlight())); let thread_id = event.thread_id().clone(); + let service_members = room + .service_members() + .unwrap_or_default() + .iter() + .map(ToString::to_string) + .collect_vec(); let item = NotificationItem { event, @@ -1041,6 +1050,7 @@ impl NotificationItem { .map(|state| state.is_encrypted()) .ok(), joined_members_count: room.joined_members_count(), + service_members, is_space: room.is_space(), is_noisy, has_mention,