From f113b430468d43c42fed76a49cc5b5dcf8703a21 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 26 Jun 2021 19:29:51 +0300 Subject: [PATCH] Use current timestamp instead of 0 for messages without `Date:` Otherwise receiving a message without `Date:` in an empty chat pushes it to the bottom of chatlist. --- src/dc_receive_imf.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index dde88d63c..665c351d6 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -90,11 +90,14 @@ pub(crate) async fn dc_receive_imf_inner( return Ok(()); } - let mut sent_timestamp = 0; - if let Some(value) = mime_parser.get(HeaderDef::Date) { - // is not yet checked against bad times! we do this later if we have the database information. - sent_timestamp = mailparse::dateparse(value).unwrap_or_default(); - } + let mut sent_timestamp = if let Some(value) = mime_parser + .get(HeaderDef::Date) + .and_then(|value| mailparse::dateparse(value).ok()) + { + value + } else { + dc_create_smeared_timestamp(context).await + }; let rfc724_mid = mime_parser.get_rfc724_mid().unwrap_or_else(|| // missing Message-IDs may come if the mail was set from this account with another