diff --git a/deltachat-jsonrpc/src/api/types/message.rs b/deltachat-jsonrpc/src/api/types/message.rs index adbb90194..e18dfd23e 100644 --- a/deltachat-jsonrpc/src/api/types/message.rs +++ b/deltachat-jsonrpc/src/api/types/message.rs @@ -1,6 +1,7 @@ use anyhow::{anyhow, Result}; use deltachat::contact::Contact; use deltachat::context::Context; +use deltachat::download::DownloadState; use deltachat::message::Message; use deltachat::message::MsgId; use deltachat::message::Viewtype; @@ -53,6 +54,8 @@ pub struct MessageObject { file_mime: Option, file_bytes: u64, file_name: Option, + + download_state: MessageDownloadState } impl MessageObject { @@ -121,6 +124,8 @@ impl MessageObject { file_mime: message.get_filemime(), file_bytes, file_name: message.get_filename(), + + download_state: message.download_state().try_into().unwrap() }) } } @@ -165,6 +170,7 @@ pub enum MessageViewtype { Webxdc, } + impl From for MessageViewtype { fn from(viewtype: Viewtype) -> Self { match viewtype { @@ -200,3 +206,36 @@ impl From for Viewtype { } } } + + +#[derive(Serialize, Deserialize, TypeDef)] +#[serde(rename = "DownloadState")] +pub enum MessageDownloadState { + Done, + Available, + Failure, + InProgress +} + + +impl From for MessageDownloadState{ + fn from(download_state: DownloadState) -> Self { + match download_state { + DownloadState::Done => MessageDownloadState::Done, + DownloadState::Available => MessageDownloadState::Available, + DownloadState::Failure => MessageDownloadState::Failure, + DownloadState::InProgress => MessageDownloadState::InProgress + } + } +} + +impl From for DownloadState { + fn from(message_download_state: MessageDownloadState) -> Self { + match message_download_state { + MessageDownloadState::Done => DownloadState::Done, + MessageDownloadState::Available => DownloadState::Available, + MessageDownloadState::Failure => DownloadState::Failure, + MessageDownloadState::InProgress => DownloadState::InProgress + } + } +} \ No newline at end of file diff --git a/deltachat-jsonrpc/typescript/generated/types.ts b/deltachat-jsonrpc/typescript/generated/types.ts index 9d07b0036..e923b067d 100644 --- a/deltachat-jsonrpc/typescript/generated/types.ts +++ b/deltachat-jsonrpc/typescript/generated/types.ts @@ -60,7 +60,8 @@ export type Viewtype=("Unknown"| "Webxdc"); export type I32=number; export type U64=number; -export type Message={"id":U32;"chatId":U32;"fromId":U32;"quotedText":(string|null);"quotedMessageId":(U32|null);"text":(string|null);"hasLocation":boolean;"hasHtml":boolean;"viewType":Viewtype;"state":U32;"timestamp":I64;"sortTimestamp":I64;"receivedTimestamp":I64;"hasDeviatingTimestamp":boolean;"subject":string;"showPadlock":boolean;"isSetupmessage":boolean;"isInfo":boolean;"isForwarded":boolean;"duration":I32;"dimensionsHeight":I32;"dimensionsWidth":I32;"videochatType":(U32|null);"videochatUrl":(string|null);"overrideSenderName":(string|null);"sender":Contact;"setupCodeBegin":(string|null);"file":(string|null);"fileMime":(string|null);"fileBytes":U64;"fileName":(string|null);}; +export type DownloadState=("Done"|"Available"|"Failure"|"InProgress"); +export type Message={"id":U32;"chatId":U32;"fromId":U32;"quotedText":(string|null);"quotedMessageId":(U32|null);"text":(string|null);"hasLocation":boolean;"hasHtml":boolean;"viewType":Viewtype;"state":U32;"timestamp":I64;"sortTimestamp":I64;"receivedTimestamp":I64;"hasDeviatingTimestamp":boolean;"subject":string;"showPadlock":boolean;"isSetupmessage":boolean;"isInfo":boolean;"isForwarded":boolean;"duration":I32;"dimensionsHeight":I32;"dimensionsWidth":I32;"videochatType":(U32|null);"videochatUrl":(string|null);"overrideSenderName":(string|null);"sender":Contact;"setupCodeBegin":(string|null);"file":(string|null);"fileMime":(string|null);"fileBytes":U64;"fileName":(string|null);"downloadState":DownloadState;}; export type WebxdcMessageInfo={ /** * The name of the app.