diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 767b87592..3620eac35 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -599,9 +599,9 @@ async fn add_parts( } // correct message_timestamp, it should not be used before, // however, we cannot do this earlier as we need from_id to be set - let (sort_timestamp, new_sent_timestamp, rcvd_timestamp) = - calc_timestamps(context, *sent_timestamp, *chat_id, !seen).await; - *sent_timestamp = new_sent_timestamp; + let rcvd_timestamp = time(); + let sort_timestamp = calc_sort_timestamp(context, *sent_timestamp, *chat_id, !seen).await; + *sent_timestamp = std::cmp::min(*sent_timestamp, rcvd_timestamp); // unarchive chat chat_id.unarchive(context).await?; @@ -827,17 +827,12 @@ async fn save_locations( } } -async fn calc_timestamps( +async fn calc_sort_timestamp( context: &Context, message_timestamp: i64, chat_id: ChatId, is_fresh_msg: bool, -) -> (i64, i64, i64) { - let rcvd_timestamp = time(); - let mut sent_timestamp = message_timestamp; - if sent_timestamp > rcvd_timestamp { - sent_timestamp = rcvd_timestamp - } +) -> i64 { let mut sort_timestamp = message_timestamp; // get newest non fresh message for this chat @@ -863,7 +858,7 @@ async fn calc_timestamps( sort_timestamp = dc_create_smeared_timestamp(context).await; } - (sort_timestamp, sent_timestamp, rcvd_timestamp) + sort_timestamp } /// This function tries extracts the group-id from the message and returns the