Skip to content

Commit fc06351

Browse files
committed
fix: only send Chat-Group-Member-Timestamps in groups
1 parent 787f54f commit fc06351

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

src/chat/chat_tests.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2495,7 +2495,9 @@ async fn test_broadcast() -> Result<()> {
24952495
}
24962496

24972497
{
2498-
let msg = bob.recv_msg(&alice.pop_sent_msg().await).await;
2498+
let sent_msg = alice.pop_sent_msg().await;
2499+
assert!(!sent_msg.payload.contains("Chat-Group-Member-Timestamps:"));
2500+
let msg = bob.recv_msg(&sent_msg).await;
24992501
assert_eq!(msg.get_text(), "ola!");
25002502
assert_eq!(msg.subject, "Broadcast list");
25012503
assert!(!msg.get_showpadlock()); // avoid leaking recipients in encryption data
@@ -3536,3 +3538,12 @@ async fn test_restore_backup_after_60_days() -> Result<()> {
35363538

35373539
Ok(())
35383540
}
3541+
3542+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
3543+
async fn test_one_to_one_chat_no_group_member_timestamps() {
3544+
let t = TestContext::new_alice().await;
3545+
let chat = t.create_chat_with_contact("bob", "bob@example.com").await;
3546+
let sent = t.send_text(chat.id, "Hi!").await;
3547+
let payload = sent.payload;
3548+
assert!(!payload.contains("Chat-Group-Member-Timestamps:"));
3549+
}

src/mimefactory.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -622,24 +622,23 @@ impl MimeFactory {
622622
);
623623
}
624624

625-
let chat_memberlist_is_stale = if let Loaded::Message { chat, .. } = &self.loaded {
626-
chat.member_list_is_stale(context).await?
627-
} else {
628-
false
629-
};
630-
631-
if !self.member_timestamps.is_empty() && !chat_memberlist_is_stale {
632-
headers.push(
633-
Header::new_with_value(
634-
"Chat-Group-Member-Timestamps".into(),
635-
self.member_timestamps
636-
.iter()
637-
.map(|ts| ts.to_string())
638-
.collect::<Vec<String>>()
639-
.join(" "),
640-
)
641-
.unwrap(),
642-
);
625+
if let Loaded::Message { chat, .. } = &self.loaded {
626+
if chat.typ == Chattype::Group
627+
&& !self.member_timestamps.is_empty()
628+
&& !chat.member_list_is_stale(context).await?
629+
{
630+
headers.push(
631+
Header::new_with_value(
632+
"Chat-Group-Member-Timestamps".into(),
633+
self.member_timestamps
634+
.iter()
635+
.map(|ts| ts.to_string())
636+
.collect::<Vec<String>>()
637+
.join(" "),
638+
)
639+
.unwrap(),
640+
);
641+
}
643642
}
644643

645644
let subject_str = self.subject_str(context).await?;

0 commit comments

Comments
 (0)