mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
Added type DownloadState
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use deltachat::contact::Contact;
|
use deltachat::contact::Contact;
|
||||||
use deltachat::context::Context;
|
use deltachat::context::Context;
|
||||||
|
use deltachat::download::DownloadState;
|
||||||
use deltachat::message::Message;
|
use deltachat::message::Message;
|
||||||
use deltachat::message::MsgId;
|
use deltachat::message::MsgId;
|
||||||
use deltachat::message::Viewtype;
|
use deltachat::message::Viewtype;
|
||||||
@@ -53,6 +54,8 @@ pub struct MessageObject {
|
|||||||
file_mime: Option<String>,
|
file_mime: Option<String>,
|
||||||
file_bytes: u64,
|
file_bytes: u64,
|
||||||
file_name: Option<String>,
|
file_name: Option<String>,
|
||||||
|
|
||||||
|
download_state: MessageDownloadState
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MessageObject {
|
impl MessageObject {
|
||||||
@@ -121,6 +124,8 @@ impl MessageObject {
|
|||||||
file_mime: message.get_filemime(),
|
file_mime: message.get_filemime(),
|
||||||
file_bytes,
|
file_bytes,
|
||||||
file_name: message.get_filename(),
|
file_name: message.get_filename(),
|
||||||
|
|
||||||
|
download_state: message.download_state().try_into().unwrap()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,6 +170,7 @@ pub enum MessageViewtype {
|
|||||||
Webxdc,
|
Webxdc,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl From<Viewtype> for MessageViewtype {
|
impl From<Viewtype> for MessageViewtype {
|
||||||
fn from(viewtype: Viewtype) -> Self {
|
fn from(viewtype: Viewtype) -> Self {
|
||||||
match viewtype {
|
match viewtype {
|
||||||
@@ -200,3 +206,36 @@ impl From<MessageViewtype> for Viewtype {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, TypeDef)]
|
||||||
|
#[serde(rename = "DownloadState")]
|
||||||
|
pub enum MessageDownloadState {
|
||||||
|
Done,
|
||||||
|
Available,
|
||||||
|
Failure,
|
||||||
|
InProgress
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl From<DownloadState> 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<MessageDownloadState> 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -60,7 +60,8 @@ export type Viewtype=("Unknown"|
|
|||||||
"Webxdc");
|
"Webxdc");
|
||||||
export type I32=number;
|
export type I32=number;
|
||||||
export type U64=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={
|
export type WebxdcMessageInfo={
|
||||||
/**
|
/**
|
||||||
* The name of the app.
|
* The name of the app.
|
||||||
|
|||||||
Reference in New Issue
Block a user