Accessible msg error and type changes

This commit is contained in:
René Rössler
2020-10-08 11:51:04 +02:00
parent 893e4b91ba
commit 9739c0305b
5 changed files with 68 additions and 16 deletions

View File

@@ -265,7 +265,7 @@ pub struct Message {
pub(crate) is_dc_message: MessengerMessage,
pub(crate) chat_blocked: Blocked,
pub(crate) location_id: u32,
pub(crate) error: String,
error: Option<String>,
pub(crate) param: Params,
}
@@ -331,7 +331,8 @@ impl Message {
msg.ephemeral_timestamp = row.get("ephemeral_timestamp")?;
msg.viewtype = row.get("type")?;
msg.state = row.get("state")?;
msg.error = row.get("error")?;
let error: String = row.get("error")?;
msg.error = Some(error).filter(|error| !error.is_empty());
msg.is_dc_message = row.get("msgrmsg")?;
let text;
@@ -750,6 +751,22 @@ impl Message {
.await
.is_ok()
}
/// 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.
pub fn error(&self) -> Option<String> {
self.error.clone()
}
}
#[derive(
@@ -1044,8 +1061,8 @@ pub async fn get_msg_info(context: &Context, msg_id: MsgId) -> String {
ret += "\n";
if !msg.error.is_empty() {
ret += &format!("Error: {}", msg.error);
if let Some(error) = msg.error.as_ref() {
ret += &format!("Error: {}", error);
}
if let Some(path) = msg.get_file(context) {