feat(ffi): allow setting the media retention policy from the FFI layer

This commit is contained in:
Benjamin Bouvier
2025-03-03 16:21:49 +01:00
parent ac3250c58b
commit 6aea4c827a
2 changed files with 15 additions and 1 deletions

View File

@@ -21,7 +21,7 @@ use matrix_sdk::{
event_cache::EventCacheError,
media::{
MediaFileHandle as SdkMediaFileHandle, MediaFormat, MediaRequestParameters,
MediaThumbnailSettings,
MediaRetentionPolicy, MediaThumbnailSettings,
},
ruma::{
api::client::{
@@ -1161,6 +1161,19 @@ impl Client {
self.inner.is_room_alias_available(&alias).await.map_err(Into::into)
}
/// Set the media retention policy.
pub async fn set_media_retention_policy(
&self,
policy: MediaRetentionPolicy,
) -> Result<(), ClientError> {
let closure = async || -> Result<_, EventCacheError> {
let store = self.inner.event_cache_store().lock().await?;
Ok(store.set_media_retention_policy(policy).await?)
};
Ok(closure().await?)
}
/// Clear all the non-critical caches for this Client instance.
///
/// - This will empty all the room's persisted event caches, so all rooms

View File

@@ -33,6 +33,7 @@ use serde::{Deserialize, Serialize};
///
/// [`EventCacheStore`]: crate::event_cache::store::EventCacheStore
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
#[non_exhaustive]
pub struct MediaRetentionPolicy {
/// The maximum authorized size of the overall media cache, in bytes.