mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
feat: jsonrpc: add late_file_message_mediasize
This commit is contained in:
@@ -49,7 +49,7 @@ use types::chat::FullChat;
|
|||||||
use types::contact::{ContactObject, VcardContact};
|
use types::contact::{ContactObject, VcardContact};
|
||||||
use types::events::Event;
|
use types::events::Event;
|
||||||
use types::http::HttpResponse;
|
use types::http::HttpResponse;
|
||||||
use types::message::{MessageData, MessageObject, MessageReadReceipt};
|
use types::message::{LateFilingMediaSize, MessageData, MessageObject, MessageReadReceipt};
|
||||||
use types::provider_info::ProviderInfo;
|
use types::provider_info::ProviderInfo;
|
||||||
use types::reactions::JSONRPCReactions;
|
use types::reactions::JSONRPCReactions;
|
||||||
use types::webxdc::WebxdcMessageInfo;
|
use types::webxdc::WebxdcMessageInfo;
|
||||||
@@ -1262,6 +1262,31 @@ impl CommandApi {
|
|||||||
MsgId::new(message_id).download_full(&ctx).await
|
MsgId::new(message_id).download_full(&ctx).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Late filing information to a message.
|
||||||
|
/// Changes the message width, height or duration, and stores it into the database.
|
||||||
|
///
|
||||||
|
/// Sometimes, the core cannot find out the width, the height or the duration
|
||||||
|
/// of an image, an audio or a video.
|
||||||
|
///
|
||||||
|
/// If, in these cases, the frontend can provide the information, it can save
|
||||||
|
/// them together with the message object for later usage.
|
||||||
|
///
|
||||||
|
/// This function should only be used if `Message.dimensions_width`, `Message.dimensions_height` or `Message.duration`
|
||||||
|
/// do not provide the expected values.
|
||||||
|
///
|
||||||
|
/// To get the stored values later, use `Message.dimensions_width`, `Message.dimensions_height` or `Message.duration`.
|
||||||
|
async fn late_file_message_mediasize(
|
||||||
|
&self,
|
||||||
|
account_id: u32,
|
||||||
|
message_id: u32,
|
||||||
|
new_size: LateFilingMediaSize,
|
||||||
|
) -> Result<()> {
|
||||||
|
let ctx = self.get_context(account_id).await?;
|
||||||
|
new_size
|
||||||
|
.apply_to_message(&ctx, MsgId::new(message_id))
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
/// Search messages containing the given query string.
|
/// Search messages containing the given query string.
|
||||||
/// Searching can be done globally (chat_id=None) or in a specified chat only (chat_id set).
|
/// Searching can be done globally (chat_id=None) or in a specified chat only (chat_id set).
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -712,3 +712,42 @@ 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 duration to store in the message object. None if you don't want to change it.
|
||||||
|
pub duration: Option<u32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
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?;
|
||||||
|
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")?,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user