combine width and height into a tuple

This commit is contained in:
Simon Laux
2025-02-16 21:30:49 +01:00
parent 3ab75f1053
commit ef8b98e1aa

View File

@@ -716,10 +716,8 @@ impl From<deltachat::ephemeral::Timer> for EphemeralTimer {
#[derive(Deserialize, TypeDef, schemars::JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct LateFilingMediaSize {
// The new width to store in the message object. None if you don't want to change the width.
pub width: Option<u32>,
// The new height to store in the message object. None if you don't want to change the height.
pub height: Option<u32>,
// The new width and height to store in the message object. None if you don't want to change the dimensions.
pub wh: Option<(u32, u32)>,
// The new duration to store in the message object. None if you don't want to change it.
pub duration: Option<u32>,
}
@@ -731,22 +729,20 @@ impl LateFilingMediaSize {
message_id: MsgId,
) -> anyhow::Result<()> {
let mut message = deltachat::message::Message::load_from_db(context, message_id).await?;
let (width, height) = match self.wh {
Some((w, h)) => (
w.to_i32().context("conversion to i32 failed")?,
h.to_i32().context("conversion to i32 failed")?,
),
None => (0, 0),
};
let duration = self
.duration
.unwrap_or(0)
.to_i32()
.context("conversion to i32 failed")?;
message
.latefiling_mediasize(
context,
self.width
.unwrap_or(0)
.to_i32()
.context("conversion to i32 failed")?,
self.height
.unwrap_or(0)
.to_i32()
.context("conversion to i32 failed")?,
self.duration
.unwrap_or(0)
.to_i32()
.context("conversion to i32 failed")?,
)
.latefiling_mediasize(context, width, height, duration)
.await?;
Ok(())
}