Skip to content

Commit cf9d058

Browse files
Johennesbnjbvr
authored andcommitted
feat(ffi): allow specifying gallery items using UploadSource
Signed-off-by: Johannes Marbach <[email protected]>
1 parent 4da13e1 commit cf9d058

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

bindings/matrix-sdk-ffi/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ All notable changes to this project will be documented in this file.
8080
- The MSRV has been bumped to Rust 1.88.
8181
([#5431](https://github.com/matrix-org/matrix-rust-sdk/pull/5431))
8282
- `Room::send_call_notification` and `Room::send_call_notification_if_needed` have been removed, since the event type they send is outdated, and `Client` is not actually supposed to be able to join MatrixRTC sessions (yet). In practice, users of these methods probably already rely on another MatrixRTC implementation to participate in sessions, and such an implementation should be capable of sending notifications itself.
83+
- The `GalleryItemInfo` variants now take an `UploadSource` rather than a `String` path to enable uploading
84+
from bytes directly.
85+
([#5529](https://github.com/matrix-org/matrix-rust-sdk/pull/5529))
8386

8487
## [0.13.0] - 2025-07-10
8588

bindings/matrix-sdk-ffi/src/timeline/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub struct UploadParameters {
198198
}
199199

200200
/// A source for uploading a file
201-
#[derive(uniffi::Enum)]
201+
#[derive(Clone, uniffi::Enum)]
202202
pub enum UploadSource {
203203
/// Upload source is a file on disk
204204
File {
@@ -1302,7 +1302,7 @@ mod galleries {
13021302
error::RoomError,
13031303
ruma::{AudioInfo, FileInfo, FormattedBody, ImageInfo, Mentions, VideoInfo},
13041304
runtime::get_runtime_handle,
1305-
timeline::{build_thumbnail_info, Timeline},
1305+
timeline::{build_thumbnail_info, Timeline, UploadSource},
13061306
};
13071307

13081308
#[derive(uniffi::Record)]
@@ -1321,26 +1321,26 @@ mod galleries {
13211321
pub enum GalleryItemInfo {
13221322
Audio {
13231323
audio_info: AudioInfo,
1324-
filename: String,
1324+
source: UploadSource,
13251325
caption: Option<String>,
13261326
formatted_caption: Option<FormattedBody>,
13271327
},
13281328
File {
13291329
file_info: FileInfo,
1330-
filename: String,
1330+
source: UploadSource,
13311331
caption: Option<String>,
13321332
formatted_caption: Option<FormattedBody>,
13331333
},
13341334
Image {
13351335
image_info: ImageInfo,
1336-
filename: String,
1336+
source: UploadSource,
13371337
caption: Option<String>,
13381338
formatted_caption: Option<FormattedBody>,
13391339
thumbnail_path: Option<String>,
13401340
},
13411341
Video {
13421342
video_info: VideoInfo,
1343-
filename: String,
1343+
source: UploadSource,
13441344
caption: Option<String>,
13451345
formatted_caption: Option<FormattedBody>,
13461346
thumbnail_path: Option<String>,
@@ -1357,12 +1357,12 @@ mod galleries {
13571357
}
13581358
}
13591359

1360-
fn filename(&self) -> &String {
1360+
fn source(&self) -> &UploadSource {
13611361
match self {
1362-
GalleryItemInfo::Audio { filename, .. } => filename,
1363-
GalleryItemInfo::File { filename, .. } => filename,
1364-
GalleryItemInfo::Image { filename, .. } => filename,
1365-
GalleryItemInfo::Video { filename, .. } => filename,
1362+
GalleryItemInfo::File { source, .. } => source,
1363+
GalleryItemInfo::Audio { source, .. } => source,
1364+
GalleryItemInfo::Image { source, .. } => source,
1365+
GalleryItemInfo::Video { source, .. } => source,
13661366
}
13671367
}
13681368

@@ -1428,7 +1428,7 @@ mod galleries {
14281428
let mime_type =
14291429
mime_str.parse::<Mime>().map_err(|_| RoomError::InvalidAttachmentMimeType)?;
14301430
Ok(matrix_sdk_ui::timeline::GalleryItemInfo {
1431-
source: self.filename().into(),
1431+
source: self.source().clone().into(),
14321432
content_type: mime_type,
14331433
attachment_info: self.attachment_info()?,
14341434
caption: self.caption().clone(),

0 commit comments

Comments
 (0)