-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: jsonrpc: add late_file_message_mediasize
#6428
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -712,3 +712,38 @@ impl From<deltachat::ephemeral::Timer> for EphemeralTimer { | |
} | ||
} | ||
} | ||
|
||
#[derive(Deserialize, TypeDef, schemars::JsonSchema)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct LateFilingMediaSize { | ||
// 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>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the unit for duration, seconds, milliseconds? |
||
} | ||
|
||
impl LateFilingMediaSize { | ||
pub async fn apply_to_message( | ||
&self, | ||
context: &Context, | ||
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() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This converts everything to i32, but then function arguments are u32 everywhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
.context("conversion to i32 failed")?; | ||
message | ||
.latefiling_mediasize(context, width, height, duration) | ||
.await?; | ||
Ok(()) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would this happen that image dimensions are wrong? If UI can determine the the image size, can it just display the image correctly, why does it need to store it back into the database and read back?