Skip to content

Commit ef8b98e

Browse files
committed
combine width and height into a tuple
1 parent 3ab75f1 commit ef8b98e

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

deltachat-jsonrpc/src/api/types/message.rs

+15-19
Original file line numberDiff line numberDiff line change
@@ -716,10 +716,8 @@ impl From<deltachat::ephemeral::Timer> for EphemeralTimer {
716716
#[derive(Deserialize, TypeDef, schemars::JsonSchema)]
717717
#[serde(rename_all = "camelCase")]
718718
pub struct LateFilingMediaSize {
719-
// The new width to store in the message object. None if you don't want to change the width.
720-
pub width: Option<u32>,
721-
// The new height to store in the message object. None if you don't want to change the height.
722-
pub height: Option<u32>,
719+
// The new width and height to store in the message object. None if you don't want to change the dimensions.
720+
pub wh: Option<(u32, u32)>,
723721
// The new duration to store in the message object. None if you don't want to change it.
724722
pub duration: Option<u32>,
725723
}
@@ -731,22 +729,20 @@ impl LateFilingMediaSize {
731729
message_id: MsgId,
732730
) -> anyhow::Result<()> {
733731
let mut message = deltachat::message::Message::load_from_db(context, message_id).await?;
732+
let (width, height) = match self.wh {
733+
Some((w, h)) => (
734+
w.to_i32().context("conversion to i32 failed")?,
735+
h.to_i32().context("conversion to i32 failed")?,
736+
),
737+
None => (0, 0),
738+
};
739+
let duration = self
740+
.duration
741+
.unwrap_or(0)
742+
.to_i32()
743+
.context("conversion to i32 failed")?;
734744
message
735-
.latefiling_mediasize(
736-
context,
737-
self.width
738-
.unwrap_or(0)
739-
.to_i32()
740-
.context("conversion to i32 failed")?,
741-
self.height
742-
.unwrap_or(0)
743-
.to_i32()
744-
.context("conversion to i32 failed")?,
745-
self.duration
746-
.unwrap_or(0)
747-
.to_i32()
748-
.context("conversion to i32 failed")?,
749-
)
745+
.latefiling_mediasize(context, width, height, duration)
750746
.await?;
751747
Ok(())
752748
}

0 commit comments

Comments
 (0)