ffi: Allow to get the user-defined notification mode for a room

This commit is contained in:
Nicolas Mauri
2023-08-09 16:29:32 +02:00
parent 51c25a4456
commit 0a52fc895e

View File

@@ -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<Option<RoomNotificationMode>, 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