Skip to content

Commit bd6361e

Browse files
mgoldenbergpoljar
authored andcommitted
feat(ffi): replace file-related fields with UploadSource in UploadParameters
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
1 parent 02fdf8c commit bd6361e

File tree

1 file changed

+7
-8
lines changed
  • bindings/matrix-sdk-ffi/src/timeline

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,11 @@ impl Timeline {
130130
.reply(params.reply_params.map(|p| p.try_into()).transpose()?);
131131

132132
let handle = SendAttachmentJoinHandle::new(get_runtime_handle().spawn(async move {
133-
let source = if let Some(bytes) = params.file_data {
134-
AttachmentSource::Data { bytes, filename: params.filename }
135-
} else {
136-
AttachmentSource::File(params.filename.into())
133+
let source = match params.source {
134+
UploadSource::Data { data, filename } => {
135+
AttachmentSource::Data { bytes: data, filename }
136+
}
137+
UploadSource::File { filename } => AttachmentSource::File(filename.into()),
137138
};
138139
let mut request = self.inner.send_attachment(source, mime_type, attachment_config);
139140

@@ -205,10 +206,8 @@ fn build_thumbnail_info(
205206

206207
#[derive(uniffi::Record)]
207208
pub struct UploadParameters {
208-
/// Filename (previously called "url") for the media to be sent.
209-
filename: String,
210-
/// Optional file data - if not present, then data is read from `filename`
211-
file_data: Option<Vec<u8>>,
209+
/// Source from which to upload data
210+
source: UploadSource,
212211
/// Optional non-formatted caption, for clients that support it.
213212
caption: Option<String>,
214213
/// Optional HTML-formatted caption, for clients that support it.

0 commit comments

Comments
 (0)