From d81579730e6e2a91aeef5fef1c76808a570574ed Mon Sep 17 00:00:00 2001 From: link2xt Date: Sun, 30 Oct 2022 10:25:27 +0000 Subject: [PATCH] Allow sender timestamp to be in the future This can happen due to unsynchronized clocks or when "smeared" timestamp is used as the sender sends multiple messages without delay. --- CHANGELOG.md | 1 + src/receive_imf.rs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41c9319f2..3be0e8877 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### API-Changes ### Changes +- allow sender timestamp to be in the future, but not too much ### Fixes - `dc_search_msgs()` returns unaccepted requests #3694 diff --git a/src/receive_imf.rs b/src/receive_imf.rs index ddf33ab35..d01fd7146 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -173,10 +173,13 @@ pub(crate) async fn receive_imf_inner( .await?; let rcvd_timestamp = smeared_time(context).await; + + // Sender timestamp is allowed to be a bit in the future due to + // unsynchronized clocks, but not too much. let sent_timestamp = mime_parser .get_header(HeaderDef::Date) .and_then(|value| mailparse::dateparse(value).ok()) - .map_or(rcvd_timestamp, |value| min(value, rcvd_timestamp)); + .map_or(rcvd_timestamp, |value| min(value, rcvd_timestamp + 60)); // Add parts let received_msg = add_parts(