From 0a52fc895ee768caa8b52af0bee7ed4419bb9cbd Mon Sep 17 00:00:00 2001 From: Nicolas Mauri Date: Wed, 9 Aug 2023 16:29:32 +0200 Subject: [PATCH] ffi: Allow to get the user-defined notification mode for a room --- .../src/notification_settings.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bindings/matrix-sdk-ffi/src/notification_settings.rs b/bindings/matrix-sdk-ffi/src/notification_settings.rs index c34dddd9d..e5fbeb078 100644 --- a/bindings/matrix-sdk-ffi/src/notification_settings.rs +++ b/bindings/matrix-sdk-ffi/src/notification_settings.rs @@ -176,6 +176,24 @@ impl NotificationSettings { Ok(()) } + /// Get the user defined room notification mode + pub async fn get_user_defined_room_notification_mode( + &self, + room_id: String, + ) -> Result, NotificationSettingsError> { + let notification_settings = self.sdk_notification_settings.read().await; + let parsed_room_id = RoomId::parse(&room_id) + .map_err(|_e| NotificationSettingsError::InvalidRoomId(room_id))?; + // Get the current user defined mode for this room + if let Some(mode) = + notification_settings.get_user_defined_room_notification_mode(&parsed_room_id).await + { + Ok(Some(mode.into())) + } else { + Ok(None) + } + } + /// Get the default room notification mode /// /// The mode will depend on the associated `PushRule` based on whether the