From c66590b8162760f23fb74fbbeb68c5671d096391 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 4 Jan 2025 05:06:04 +0000 Subject: [PATCH] Send Chat-Group-Member-Timestamps --- src/mimefactory.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/mimefactory.rs b/src/mimefactory.rs index 87a13505a5..da280cab64 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -72,6 +72,13 @@ pub struct MimeFactory { /// Vector of pairs of past group member name and addresses. past_members: Vec<(String, String)>, + /// Timestamps of the members in the same order as in the `recipients` + /// followed by `past_members`. + /// + /// If this is not empty, its length + /// should be the sum of `recipients` and `past_members` length. + member_timestamps: Vec, + timestamp: i64, loaded: Loaded, in_reply_to: String, @@ -150,6 +157,7 @@ impl MimeFactory { let mut recipients = Vec::with_capacity(5); let mut past_members = Vec::new(); + let mut member_timestamps = Vec::new(); let mut recipient_ids = HashSet::new(); let mut req_mdn = false; @@ -190,6 +198,7 @@ impl MimeFactory { if add_timestamp >= remove_timestamp { if !recipients_contain_addr(&recipients, &addr) { recipients.push((name, addr)); + member_timestamps.push(add_timestamp); } recipient_ids.insert(id); } else { @@ -197,6 +206,7 @@ impl MimeFactory { // member is not actually part of the group. if !recipients_contain_addr(&past_members, &addr) { past_members.push((name, addr)); + member_timestamps.push(remove_timestamp); } } } @@ -204,6 +214,7 @@ impl MimeFactory { }, ) .await?; + let recipient_ids: Vec<_> = recipient_ids.into_iter().collect(); ContactId::scaleup_origin(context, &recipient_ids, Origin::OutgoingTo).await?; @@ -240,6 +251,7 @@ impl MimeFactory { }; let attach_selfavatar = Self::should_attach_selfavatar(context, &msg).await; + debug_assert!(member_timestamps.is_empty() || recipients.len() + past_members.len() == member_timestamps.len()); let factory = MimeFactory { from_addr, from_displayname, @@ -247,6 +259,7 @@ impl MimeFactory { selfstatus, recipients, past_members, + member_timestamps, timestamp: msg.timestamp_sort, loaded: Loaded::Message { msg, chat }, in_reply_to, @@ -276,6 +289,7 @@ impl MimeFactory { selfstatus: "".to_string(), recipients: vec![("".to_string(), contact.get_addr().to_string())], past_members: vec![], + member_timestamps: vec![], timestamp, loaded: Loaded::Mdn { rfc724_mid, @@ -569,6 +583,10 @@ impl MimeFactory { ); } + if !self.member_timestamps.is_empty() { + // TODO send `Chat-Member-Timestamps`. + } + let subject_str = self.subject_str(context).await?; let encoded_subject = if subject_str .chars()