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
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
impl Message
sourcepub fn download_state(&self) -> DownloadState
pub fn download_state(&self) -> DownloadState
Returns the download state of the message.
source§impl Message
impl Message
sourcepub async fn load_from_db(context: &Context, id: MsgId) -> Result<Message>
pub async fn load_from_db(context: &Context, id: MsgId) -> Result<Message>
Loads message with given ID from the database.
Returns an error if the message does not exist.
sourcepub async fn load_from_db_optional(
context: &Context,
id: MsgId,
) -> Result<Option<Message>>
pub async fn load_from_db_optional( context: &Context, id: MsgId, ) -> Result<Option<Message>>
Loads message with given ID from the database.
Returns None
if the message does not exist.
sourcepub fn get_filemime(&self) -> Option<String>
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.
sourcepub fn get_file(&self, context: &Context) -> Option<PathBuf>
pub fn get_file(&self, context: &Context) -> Option<PathBuf>
Returns the full path to the file associated with a message.
sourcepub async fn vcard_contacts(
&self,
context: &Context,
) -> Result<Vec<VcardContact>>
pub async fn vcard_contacts( &self, context: &Context, ) -> Result<Vec<VcardContact>>
Returns vector of vcards if the file has a vCard attachment.
sourcepub async fn save_file(&self, context: &Context, path: &Path) -> Result<()>
pub async fn save_file(&self, context: &Context, path: &Path) -> Result<()>
Save file copy at the user-provided path.
sourcepub(crate) async fn try_calc_and_set_dimensions(
&mut self,
context: &Context,
) -> Result<()>
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
sourcepub fn has_location(&self) -> bool
pub fn has_location(&self) -> bool
Check if a message has a POI location bound to it.
These locations are also returned by location::get_range()
.
The UI may decide to display a special icon beside such messages.
sourcepub fn set_location(&mut self, latitude: f64, longitude: f64)
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 location::set()
and send_locations_to_chat()
.
Typically results in the event LocationChanged
with
contact_id
set to ContactId::SELF
.
latitude
is the North-south position of the location.
longitutde
is the East-west position of the location.
sourcepub fn get_timestamp(&self) -> i64
pub fn get_timestamp(&self) -> i64
Returns the message timestamp for display in the UI as a unix timestamp in seconds.
sourcepub fn rfc724_mid(&self) -> &str
pub fn rfc724_mid(&self) -> &str
Returns the rfc724 message ID May be empty
sourcepub fn get_from_id(&self) -> ContactId
pub fn get_from_id(&self) -> ContactId
Returns the ID of the contact who wrote the message.
sourcepub fn get_chat_id(&self) -> ChatId
pub fn get_chat_id(&self) -> ChatId
Returns the chat ID.
sourcepub fn get_viewtype(&self) -> Viewtype
pub fn get_viewtype(&self) -> Viewtype
Returns the type of the message.
sourcepub fn force_sticker(&mut self)
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.
sourcepub fn get_state(&self) -> MessageState
pub fn get_state(&self) -> MessageState
Returns the state of the message.
sourcepub fn get_received_timestamp(&self) -> i64
pub fn get_received_timestamp(&self) -> i64
Returns the message receive time as a unix timestamp in seconds.
sourcepub fn get_sort_timestamp(&self) -> i64
pub fn get_sort_timestamp(&self) -> i64
Returns the timestamp of the message for sorting.
sourcepub fn get_subject(&self) -> &str
pub fn get_subject(&self) -> &str
Returns message subject.
sourcepub fn get_filename(&self) -> Option<String>
pub fn get_filename(&self) -> Option<String>
Returns original filename (as shown in chat).
To get the full path, use Self::get_file()
.
sourcepub async fn get_filebytes(&self, context: &Context) -> Result<Option<u64>>
pub async fn get_filebytes(&self, context: &Context) -> Result<Option<u64>>
Returns the size of the file in bytes, if applicable.
sourcepub fn get_height(&self) -> i32
pub fn get_height(&self) -> i32
Returns height of associated image or video file.
sourcepub fn get_duration(&self) -> i32
pub fn get_duration(&self) -> i32
Returns duration of associated audio or video file.
sourcepub fn get_showpadlock(&self) -> bool
pub fn get_showpadlock(&self) -> bool
Returns true if padlock indicating message encryption should be displayed in the UI.
sourcepub fn get_ephemeral_timer(&self) -> EphemeralTimer
pub fn get_ephemeral_timer(&self) -> EphemeralTimer
Return the ephemeral timer duration for a message.
sourcepub fn get_ephemeral_timestamp(&self) -> i64
pub fn get_ephemeral_timestamp(&self) -> i64
Returns the timestamp of the epehemeral message removal.
sourcepub async fn get_summary(
&self,
context: &Context,
chat: Option<&Chat>,
) -> Result<Summary>
pub async fn get_summary( &self, context: &Context, chat: Option<&Chat>, ) -> Result<Summary>
Returns message summary for display in the search results.
sourcepub fn get_override_sender_name(&self) -> Option<String>
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.
pub(crate) fn get_sender_name(&self, contact: &Contact) -> String
sourcepub fn has_deviating_timestamp(&self) -> bool
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.
sourcepub fn is_sent(&self) -> bool
pub fn is_sent(&self) -> bool
Returns true if the message was successfully delivered to the outgoing server or even received a read receipt.
sourcepub fn is_forwarded(&self) -> bool
pub fn is_forwarded(&self) -> bool
Returns true if the message is a forwarded message.
sourcepub fn get_info_type(&self) -> SystemMessage
pub fn get_info_type(&self) -> SystemMessage
Returns the type of an informational message.
sourcepub fn is_system_message(&self) -> bool
pub fn is_system_message(&self) -> bool
Returns true if the message is a system message.
sourcepub fn is_increation(&self) -> bool
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.
sourcepub fn is_setupmessage(&self) -> bool
pub fn is_setupmessage(&self) -> bool
Returns true if the message is an Autocrypt Setup Message.
sourcepub async fn get_setupcodebegin(&self, context: &Context) -> Option<String>
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.
pub(crate) fn create_webrtc_instance(instance: &str, room: &str) -> String
sourcepub fn parse_webrtc_instance(instance: &str) -> (VideochatType, String)
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
sourcepub fn get_videochat_url(&self) -> Option<String>
pub fn get_videochat_url(&self) -> Option<String>
Returns videochat URL if the message is a videochat invitation.
sourcepub fn get_videochat_type(&self) -> Option<VideochatType>
pub fn get_videochat_type(&self) -> Option<VideochatType>
Returns videochat type if the message is a videochat invitation.
sourcepub fn set_subject(&mut self, subject: String)
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>
).
sourcepub fn set_file(&mut self, file: impl ToString, filemime: Option<&str>)
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.
sourcepub async fn set_file_from_bytes(
&mut self,
context: &Context,
suggested_name: &str,
data: &[u8],
filemime: Option<&str>,
) -> Result<()>
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.
sourcepub async fn make_vcard(
&mut self,
context: &Context,
contacts: &[ContactId],
) -> Result<()>
pub async fn make_vcard( &mut self, context: &Context, contacts: &[ContactId], ) -> Result<()>
Makes message a vCard-containing message using the specified contacts.
sourcepub(crate) async fn try_set_vcard(
&mut self,
context: &Context,
path: &Path,
) -> Result<()>
pub(crate) async fn try_set_vcard( &mut self, context: &Context, path: &Path, ) -> Result<()>
Updates message state from the vCard attachment.
sourcepub fn set_override_sender_name(&mut self, name: Option<String>)
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
.
sourcepub fn set_dimension(&mut self, width: i32, height: i32)
pub fn set_dimension(&mut self, width: i32, height: i32)
Sets the dimensions of associated image or video file.
sourcepub fn set_duration(&mut self, duration: i32)
pub fn set_duration(&mut self, duration: i32)
Sets the duration of associated audio or video file.
sourcepub(crate) fn set_reaction(&mut self)
pub(crate) fn set_reaction(&mut self)
Marks the message as reaction.
sourcepub async fn latefiling_mediasize(
&mut self,
context: &Context,
width: i32,
height: i32,
duration: i32,
) -> Result<()>
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.
sourcepub fn set_quote_text(&mut self, text: Option<(String, bool)>)
pub fn set_quote_text(&mut self, text: Option<(String, bool)>)
Sets message quote text.
If text
is Some((text_str, protect))
, protect
specifies whether text_str
should only
be sent encrypted. If it should, but the message is unencrypted, text_str
is replaced with
“…”.
sourcepub async fn set_quote(
&mut self,
context: &Context,
quote: Option<&Message>,
) -> Result<()>
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.
sourcepub fn quoted_text(&self) -> Option<String>
pub fn quoted_text(&self) -> Option<String>
Returns quoted message text, if any.
sourcepub async fn quoted_message(&self, context: &Context) -> Result<Option<Message>>
pub async fn quoted_message(&self, context: &Context) -> Result<Option<Message>>
Returns quoted message, if any.
sourcepub async fn parent(&self, context: &Context) -> Result<Option<Message>>
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.
sourcepub fn force_plaintext(&mut self)
pub fn force_plaintext(&mut self)
Force the message to be sent in plain text.
sourcepub async fn update_param(&self, context: &Context) -> Result<()>
pub async fn update_param(&self, context: &Context) -> Result<()>
Updates param
column of the message in the database without changing other columns.
pub(crate) async fn update_subject(&self, context: &Context) -> Result<()>
sourcepub fn error(&self) -> Option<String>
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
impl Message
sourceasync fn get_webxdc_archive(&self, context: &Context) -> Result<FsZipFileReader>
async fn get_webxdc_archive(&self, context: &Context) -> Result<FsZipFileReader>
Get handle to a webxdc ZIP-archive. To check for file existence use archive.by_name(), to read a file, use get_blob(archive).
sourcepub async fn get_webxdc_blob(
&self,
context: &Context,
name: &str,
) -> Result<Vec<u8>>
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
.
sourcepub async fn get_webxdc_info(&self, context: &Context) -> Result<WebxdcInfo>
pub async fn get_webxdc_info(&self, context: &Context) -> Result<WebxdcInfo>
Return info from manifest.toml or from fallbacks.
source§impl Message
impl Message
sourcepub fn has_html(&self) -> bool
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()
.
sourcepub fn set_html(&mut self, html: Option<String>)
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”)
Trait Implementations§
source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)