Skip to content

Commit 2c16e9b

Browse files
committed
Send Chat-Group-Member-Timestamps
1 parent b1718da commit 2c16e9b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/mimefactory.rs

+21
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ pub struct MimeFactory {
7272
/// Vector of pairs of past group member name and addresses.
7373
past_members: Vec<(String, String)>,
7474

75+
/// Timestamps of the members in the same order as in the `recipients`
76+
/// followed by `past_members`.
77+
///
78+
/// If this is not empty, its length
79+
/// should be the sum of `recipients` and `past_members` length.
80+
member_timestamps: Vec<i64>,
81+
7582
timestamp: i64,
7683
loaded: Loaded,
7784
in_reply_to: String,
@@ -150,6 +157,7 @@ impl MimeFactory {
150157

151158
let mut recipients = Vec::with_capacity(5);
152159
let mut past_members = Vec::new();
160+
let mut member_timestamps = Vec::new();
153161
let mut recipient_ids = HashSet::new();
154162
let mut req_mdn = false;
155163

@@ -190,20 +198,23 @@ impl MimeFactory {
190198
if add_timestamp >= remove_timestamp {
191199
if !recipients_contain_addr(&recipients, &addr) {
192200
recipients.push((name, addr));
201+
member_timestamps.push(add_timestamp);
193202
}
194203
recipient_ids.insert(id);
195204
} else {
196205
// Row is a tombstone,
197206
// member is not actually part of the group.
198207
if !recipients_contain_addr(&past_members, &addr) {
199208
past_members.push((name, addr));
209+
member_timestamps.push(remove_timestamp);
200210
}
201211
}
202212
}
203213
Ok(())
204214
},
205215
)
206216
.await?;
217+
207218
let recipient_ids: Vec<_> = recipient_ids.into_iter().collect();
208219
ContactId::scaleup_origin(context, &recipient_ids, Origin::OutgoingTo).await?;
209220

@@ -240,13 +251,18 @@ impl MimeFactory {
240251
};
241252
let attach_selfavatar = Self::should_attach_selfavatar(context, &msg).await;
242253

254+
debug_assert!(
255+
member_timestamps.is_empty()
256+
|| recipients.len() + past_members.len() == member_timestamps.len()
257+
);
243258
let factory = MimeFactory {
244259
from_addr,
245260
from_displayname,
246261
sender_displayname,
247262
selfstatus,
248263
recipients,
249264
past_members,
265+
member_timestamps,
250266
timestamp: msg.timestamp_sort,
251267
loaded: Loaded::Message { msg, chat },
252268
in_reply_to,
@@ -276,6 +292,7 @@ impl MimeFactory {
276292
selfstatus: "".to_string(),
277293
recipients: vec![("".to_string(), contact.get_addr().to_string())],
278294
past_members: vec![],
295+
member_timestamps: vec![],
279296
timestamp,
280297
loaded: Loaded::Mdn {
281298
rfc724_mid,
@@ -569,6 +586,10 @@ impl MimeFactory {
569586
);
570587
}
571588

589+
if !self.member_timestamps.is_empty() {
590+
// TODO send `Chat-Member-Timestamps`.
591+
}
592+
572593
let subject_str = self.subject_str(context).await?;
573594
let encoded_subject = if subject_str
574595
.chars()

0 commit comments

Comments
 (0)