Skip to content

Commit

Permalink
Send Chat-Group-Member-Timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Jan 4, 2025
1 parent b1718da commit c66590b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/mimefactory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<i64>,

timestamp: i64,
loaded: Loaded,
in_reply_to: String,
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -190,20 +198,23 @@ 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 {
// Row is a tombstone,
// 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);
}
}
}
Ok(())
},
)
.await?;

let recipient_ids: Vec<_> = recipient_ids.into_iter().collect();
ContactId::scaleup_origin(context, &recipient_ids, Origin::OutgoingTo).await?;

Expand Down Expand Up @@ -240,13 +251,15 @@ 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,
sender_displayname,
selfstatus,
recipients,
past_members,
member_timestamps,
timestamp: msg.timestamp_sort,
loaded: Loaded::Message { msg, chat },
in_reply_to,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit c66590b

Please sign in to comment.