Set subject to Re: <last subject> for better compability with normal MUAs

The code in dc_receive_imf.rs looks a bit funny, an alternative would be a function:

fn upcate_chat_last_subject(context: &Context, chat_id: &ChatId, mime_parser: &mut MimeMessage) -> Result<()> {
    let mut chat = Chat::load_from_db(context, *chat_id)?;
    chat.param.set(Param::LastSubject, mime_parser.get_subject().ok_or_else(||Error::Message("No subject in email".to_string()))?);
    chat.update_param(context)?;
    Ok(())
}
This commit is contained in:
Hocuri
2020-04-14 21:38:28 +02:00
committed by holger krekel
parent 30c76976fc
commit f8680724f8
3 changed files with 170 additions and 11 deletions

View File

@@ -10,7 +10,7 @@ use crate::constants::*;
use crate::contact::*;
use crate::context::Context;
use crate::dc_tools::*;
use crate::error::{bail, ensure, Result};
use crate::error::{bail, ensure, format_err, Result};
use crate::events::Event;
use crate::headerdef::HeaderDef;
use crate::job::{self, Action};
@@ -749,6 +749,25 @@ async fn add_parts(
}
}
|| -> Result<()> {
let mut chat = Chat::load_from_db(context, *chat_id)?;
chat.param.set(
Param::LastSubject,
mime_parser
.get_subject()
.ok_or_else(|| format_err!("No subject in email"))?,
);
chat.update_param(context)?;
Ok(())
}()
.unwrap_or_else(|e| {
warn!(
context,
"Could not update LastSubject of chat: {}",
e.to_string()
)
});
Ok(())
}