Struct deltachat::message::Message

source ·
pub struct Message {
Show 23 fields pub(crate) id: MsgId, pub(crate) from_id: ContactId, pub(crate) to_id: ContactId, pub(crate) chat_id: ChatId, pub(crate) viewtype: Viewtype, pub(crate) state: MessageState, pub(crate) download_state: DownloadState, pub(crate) hidden: bool, pub(crate) timestamp_sort: i64, pub(crate) timestamp_sent: i64, pub(crate) timestamp_rcvd: i64, pub(crate) ephemeral_timer: Timer, pub(crate) ephemeral_timestamp: i64, pub(crate) text: String, pub(crate) subject: String, pub(crate) rfc724_mid: String, pub(crate) in_reply_to: Option<String>, pub(crate) is_dc_message: MessengerMessage, pub(crate) mime_modified: bool, pub(crate) chat_blocked: Blocked, pub(crate) location_id: u32, pub(crate) error: Option<String>, pub(crate) param: Params,
}
Expand description

An object representing a single message in memory. The message object is not updated. If you want an update, you have to recreate the object.

Fields§

§id: MsgId

Message ID.

§from_id: ContactId

From: contact ID.

§to_id: ContactId

ID of the first contact in the To: header.

§chat_id: ChatId

ID of the chat message belongs to.

§viewtype: Viewtype

Type of the message.

§state: MessageState

State of the message.

§download_state: DownloadState§hidden: bool

Whether the message is hidden.

§timestamp_sort: i64§timestamp_sent: i64§timestamp_rcvd: i64§ephemeral_timer: Timer§ephemeral_timestamp: i64§text: String§subject: String

Message subject.

If empty, a default subject will be generated when sending.

§rfc724_mid: String

Message-ID header value.

§in_reply_to: Option<String>

In-Reply-To header value.

§is_dc_message: MessengerMessage§mime_modified: bool§chat_blocked: Blocked§location_id: u32§error: Option<String>§param: Params

Implementations§

source§

impl Message

source

pub fn download_state(&self) -> DownloadState

Returns the download state of the message.

source§

impl Message

source

pub fn new(viewtype: Viewtype) -> Self

Creates a new message with given view type.

source

pub async fn load_from_db(context: &Context, id: MsgId) -> Result<Message>

Loads message with given ID from the database.

source

pub fn get_filemime(&self) -> Option<String>

Returns the MIME type of an attached file if it exists.

If the MIME type is not known, the function guesses the MIME type from the extension. application/octet-stream is used as a fallback if MIME type is not known, but None is only returned if no file is attached.

source

pub fn get_file(&self, context: &Context) -> Option<PathBuf>

Returns the full path to the file associated with a message.

source

pub(crate) async fn try_calc_and_set_dimensions( &mut self, context: &Context ) -> Result<()>

If message is an image or gif, set Param::Width and Param::Height

source

pub fn has_location(&self) -> bool

Check if a message has a location bound to it. These messages are also returned by get_locations() and the UI may decide to display a special icon beside such messages,

@memberof Message @param msg The message object. @return 1=Message has location bound to it, 0=No location bound to message.

source

pub fn set_location(&mut self, latitude: f64, longitude: f64)

Set any location that should be bound to the message object. The function is useful to add a marker to the map at a position different from the self-location. You should not call this function if you want to bind the current self-location to a message; this is done by set_location() and send_locations_to_chat().

Typically results in the event #DC_EVENT_LOCATION_CHANGED with contact_id set to ContactId::SELF.

@param latitude North-south position of the location. @param longitude East-west position of the location.

source

pub fn get_timestamp(&self) -> i64

Returns the message timestamp for display in the UI as a unix timestamp in seconds.

source

pub fn get_id(&self) -> MsgId

Returns the message ID.

source

pub fn rfc724_mid(&self) -> &str

Returns the rfc724 message ID May be empty

source

pub fn get_from_id(&self) -> ContactId

Returns the ID of the contact who wrote the message.

source

pub fn get_chat_id(&self) -> ChatId

Returns the chat ID.

source

pub fn get_viewtype(&self) -> Viewtype

Returns the type of the message.

source

pub fn force_sticker(&mut self)

Forces the message to keep Viewtype::Sticker e.g the message will not be converted to a Viewtype::Image.

source

pub fn get_state(&self) -> MessageState

Returns the state of the message.

source

pub fn get_received_timestamp(&self) -> i64

Returns the message receive time as a unix timestamp in seconds.

source

pub fn get_sort_timestamp(&self) -> i64

Returns the timestamp of the message for sorting.

source

pub fn get_text(&self) -> String

Returns the text of the message.

source

pub fn get_subject(&self) -> &str

Returns message subject.

source

pub fn get_filename(&self) -> Option<String>

Returns original filename (as shown in chat).

To get the full path, use Self::get_file().

source

pub async fn get_filebytes(&self, context: &Context) -> Result<Option<u64>>

Returns the size of the file in bytes, if applicable.

source

pub fn get_width(&self) -> i32

Returns width of associated image or video file.

source

pub fn get_height(&self) -> i32

Returns height of associated image or video file.

source

pub fn get_duration(&self) -> i32

Returns duration of associated audio or video file.

source

pub fn get_showpadlock(&self) -> bool

Returns true if padlock indicating message encryption should be displayed in the UI.

source

pub fn is_bot(&self) -> bool

Returns true if message is auto-generated.

source

pub fn get_ephemeral_timer(&self) -> EphemeralTimer

Return the ephemeral timer duration for a message.

source

pub fn get_ephemeral_timestamp(&self) -> i64

Returns the timestamp of the epehemeral message removal.

source

pub async fn get_summary( &self, context: &Context, chat: Option<&Chat> ) -> Result<Summary>

Returns message summary for display in the search results.

source

pub fn get_override_sender_name(&self) -> Option<String>

Returns the name that should be shown over the message instead of the contact display ame.

source

pub(crate) fn get_sender_name(&self, contact: &Contact) -> String

source

pub fn has_deviating_timestamp(&self) -> bool

Returns true if a message has a deviating timestamp.

A message has a deviating timestamp when it is sent on another day as received/sorted by.

source

pub fn is_sent(&self) -> bool

Returns true if the message was successfully delivered to the outgoing server or even received a read receipt.

source

pub fn is_forwarded(&self) -> bool

Returns true if the message is a forwarded message.

source

pub fn is_info(&self) -> bool

Returns true if the message is an informational message.

source

pub fn get_info_type(&self) -> SystemMessage

Returns the type of an informational message.

source

pub fn is_system_message(&self) -> bool

Returns true if the message is a system message.

source

pub fn is_increation(&self) -> bool

Whether the message is still being created.

Messages with attachments might be created before the attachment is ready. In this case some more restrictions on the attachment apply, e.g. if the file to be attached is still being written to or otherwise will still change it can not be copied to the blobdir. Thus those attachments need to be created immediately in the blobdir with a valid filename.

source

pub fn is_setupmessage(&self) -> bool

Returns true if the message is an Autocrypt Setup Message.

source

pub async fn get_setupcodebegin(&self, context: &Context) -> Option<String>

Returns the first characters of the setup code.

This is used to pre-fill the first entry field of the setup code.

source

pub(crate) fn create_webrtc_instance(instance: &str, room: &str) -> String

source

pub fn parse_webrtc_instance(instance: &str) -> (VideochatType, String)

split a webrtc_instance as defined by the corresponding config-value into a type and a url

source

pub fn get_videochat_url(&self) -> Option<String>

Returns videochat URL if the message is a videochat invitation.

source

pub fn get_videochat_type(&self) -> Option<VideochatType>

Returns videochat type if the message is a videochat invitation.

source

pub fn set_text(&mut self, text: String)

Sets or unsets message text.

source

pub fn set_subject(&mut self, subject: String)

Sets the email’s subject. If it’s empty, a default subject will be used (e.g. Message from Alice or Re: <last subject>).

source

pub fn set_file(&mut self, file: impl ToString, filemime: Option<&str>)

Sets the file associated with a message.

This function does not use the file or check if it exists, the file will only be used when the message is prepared for sending.

source

pub async fn set_file_from_bytes( &mut self, context: &Context, suggested_name: &str, data: &[u8], filemime: Option<&str> ) -> Result<()>

Creates a new blob and sets it as a file associated with a message.

source

pub fn set_override_sender_name(&mut self, name: Option<String>)

Set different sender name for a message. This overrides the name set by the set_config()-option displayname.

source

pub fn set_dimension(&mut self, width: i32, height: i32)

Sets the dimensions of associated image or video file.

source

pub fn set_duration(&mut self, duration: i32)

Sets the duration of associated audio or video file.

source

pub(crate) fn set_reaction(&mut self)

Marks the message as reaction.

source

pub async fn latefiling_mediasize( &mut self, context: &Context, width: i32, height: i32, duration: i32 ) -> Result<()>

Changes the message width, height or duration, and stores it into the database.

source

pub async fn set_quote( &mut self, context: &Context, quote: Option<&Message> ) -> Result<()>

Sets message quote.

Message-Id is used to set Reply-To field, message text is used for quote.

Encryption is required if quoted message was encrypted.

The message itself is not required to exist in the database, it may even be deleted from the database by the time the message is prepared.

source

pub fn quoted_text(&self) -> Option<String>

Returns quoted message text, if any.

source

pub async fn quoted_message(&self, context: &Context) -> Result<Option<Message>>

Returns quoted message, if any.

source

pub async fn parent(&self, context: &Context) -> Result<Option<Message>>

Returns parent message according to the In-Reply-To header if it exists in the database and is not trashed.

References header is not taken into account.

source

pub fn force_plaintext(&mut self)

Force the message to be sent in plain text.

source

pub async fn update_param(&self, context: &Context) -> Result<()>

Updates param column of the message in the database without changing other columns.

source

pub(crate) async fn update_subject(&self, context: &Context) -> Result<()>

source

pub fn error(&self) -> Option<String>

Gets the error status of the message.

A message can have an associated error status if something went wrong when sending or receiving message itself. The error status is free-form text and should not be further parsed, rather it’s presence is meant to indicate something went wrong with the message and the text of the error is detailed information on what.

Some common reasons error can be associated with messages are:

  • Lack of valid signature on an e2ee message, usually for received messages.
  • Failure to decrypt an e2ee message, usually for received messages.
  • When a message could not be delivered to one or more recipients the non-delivery notification text can be stored in the error status.
source§

impl Message

source

async fn get_webxdc_archive(&self, context: &Context) -> Result<ZipFileReader>

Get handle to a webxdc ZIP-archive. To check for file existence use archive.by_name(), to read a file, use get_blob(archive).

source

pub async fn get_webxdc_blob( &self, context: &Context, name: &str ) -> Result<Vec<u8>>

Return file from inside an archive. Currently, this works only if the message is an webxdc instance.

name is the filename within the archive, e.g. index.html.

source

pub async fn get_webxdc_info(&self, context: &Context) -> Result<WebxdcInfo>

Return info from manifest.toml or from fallbacks.

source§

impl Message

source

pub fn has_html(&self) -> bool

Check if the message can be retrieved as HTML. Typically, this is the case, when the mime structure of a Message is modified, meaning that some text is cut or the original message is in HTML and simplify() may hide some maybe important information. The corresponding ffi-function is dc_msg_has_html(). To get the HTML-code of the message, use MsgId.get_html().

source

pub fn set_html(&mut self, html: Option<String>)

Set HTML-part part of a message that is about to be sent. The HTML-part is written to the database before sending and used as the text/html part in the MIME-structure.

Received HTML parts are handled differently, they are saved together with the whole MIME-structure in mime_headers and the HTML-part is extracted using MsgId::get_html(). (To underline this asynchronicity, we are using the wording “SendHtml”)

source§

impl Message

source

async fn get_summary_text(&self, context: &Context) -> String

Returns a summary text.

Trait Implementations§

source§

impl Clone for Message

source§

fn clone(&self) -> Message

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Message

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Message

source§

fn default() -> Message

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Message

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for Message

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> RpcMessage for T
where T: Debug + Serialize + DeserializeOwned + Send + Sync + Unpin + 'static,