mirror of
https://github.com/chatmail/core.git
synced 2026-04-21 15:36:30 +03:00
fix: only send Chat-Group-Member-Timestamps in groups
This commit is contained in:
@@ -2495,7 +2495,9 @@ async fn test_broadcast() -> Result<()> {
|
||||
}
|
||||
|
||||
{
|
||||
let msg = bob.recv_msg(&alice.pop_sent_msg().await).await;
|
||||
let sent_msg = alice.pop_sent_msg().await;
|
||||
assert!(!sent_msg.payload.contains("Chat-Group-Member-Timestamps:"));
|
||||
let msg = bob.recv_msg(&sent_msg).await;
|
||||
assert_eq!(msg.get_text(), "ola!");
|
||||
assert_eq!(msg.subject, "Broadcast list");
|
||||
assert!(!msg.get_showpadlock()); // avoid leaking recipients in encryption data
|
||||
@@ -3536,3 +3538,12 @@ async fn test_restore_backup_after_60_days() -> Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_one_to_one_chat_no_group_member_timestamps() {
|
||||
let t = TestContext::new_alice().await;
|
||||
let chat = t.create_chat_with_contact("bob", "bob@example.com").await;
|
||||
let sent = t.send_text(chat.id, "Hi!").await;
|
||||
let payload = sent.payload;
|
||||
assert!(!payload.contains("Chat-Group-Member-Timestamps:"));
|
||||
}
|
||||
|
||||
@@ -622,24 +622,23 @@ impl MimeFactory {
|
||||
);
|
||||
}
|
||||
|
||||
let chat_memberlist_is_stale = if let Loaded::Message { chat, .. } = &self.loaded {
|
||||
chat.member_list_is_stale(context).await?
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
if !self.member_timestamps.is_empty() && !chat_memberlist_is_stale {
|
||||
headers.push(
|
||||
Header::new_with_value(
|
||||
"Chat-Group-Member-Timestamps".into(),
|
||||
self.member_timestamps
|
||||
.iter()
|
||||
.map(|ts| ts.to_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join(" "),
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
if let Loaded::Message { chat, .. } = &self.loaded {
|
||||
if chat.typ == Chattype::Group
|
||||
&& !self.member_timestamps.is_empty()
|
||||
&& !chat.member_list_is_stale(context).await?
|
||||
{
|
||||
headers.push(
|
||||
Header::new_with_value(
|
||||
"Chat-Group-Member-Timestamps".into(),
|
||||
self.member_timestamps
|
||||
.iter()
|
||||
.map(|ts| ts.to_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join(" "),
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let subject_str = self.subject_str(context).await?;
|
||||
|
||||
Reference in New Issue
Block a user