From 7d03d4ce0dddec4424694732cf6603830a21c8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Wed, 28 May 2025 07:45:31 +0200 Subject: [PATCH] feat(ffi): Add `Client::get_max_media_upload_size` function This allows the clients to know the max upload size for a media file and try to compress if it's too large for the homeserver. --- bindings/matrix-sdk-ffi/src/client.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bindings/matrix-sdk-ffi/src/client.rs b/bindings/matrix-sdk-ffi/src/client.rs index 0574ee017..7ae93960c 100644 --- a/bindings/matrix-sdk-ffi/src/client.rs +++ b/bindings/matrix-sdk-ffi/src/client.rs @@ -1553,6 +1553,13 @@ impl Client { ) -> Result, ClientError> { Ok(self.inner.account().fetch_media_preview_config_event_content().await?.map(Into::into)) } + + /// Gets the `max_upload_size` value from the homeserver, which controls the + /// max size a media upload request can have. + pub async fn get_max_media_upload_size(&self) -> Result { + let max_upload_size = self.inner.load_or_fetch_max_upload_size().await?; + Ok(max_upload_size.into()) + } } #[matrix_sdk_ffi_macros::export(callback_interface)]