mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 01:16:31 +03:00
feat: Hide To header in encrypted messages
This commit is contained in:
@@ -661,8 +661,6 @@ def test_download_limit_chat_assignment(acfactory, tmp_path, n_accounts):
|
|||||||
contact = alice.create_contact(account)
|
contact = alice.create_contact(account)
|
||||||
alice_group.add_contact(contact)
|
alice_group.add_contact(contact)
|
||||||
|
|
||||||
if n_accounts == 2:
|
|
||||||
bob_chat_alice = bob.create_chat(alice)
|
|
||||||
bob.set_config("download_limit", str(download_limit))
|
bob.set_config("download_limit", str(download_limit))
|
||||||
|
|
||||||
alice_group.send_text("hi")
|
alice_group.send_text("hi")
|
||||||
@@ -678,15 +676,7 @@ def test_download_limit_chat_assignment(acfactory, tmp_path, n_accounts):
|
|||||||
alice_group.send_file(str(path))
|
alice_group.send_file(str(path))
|
||||||
snapshot = bob.wait_for_incoming_msg().get_snapshot()
|
snapshot = bob.wait_for_incoming_msg().get_snapshot()
|
||||||
assert snapshot.download_state == DownloadState.AVAILABLE
|
assert snapshot.download_state == DownloadState.AVAILABLE
|
||||||
if n_accounts > 2:
|
|
||||||
assert snapshot.chat == bob_group
|
assert snapshot.chat == bob_group
|
||||||
else:
|
|
||||||
# Group contains only Alice and Bob,
|
|
||||||
# so partially downloaded messages are
|
|
||||||
# hard to distinguish from private replies to group messages.
|
|
||||||
#
|
|
||||||
# Message may be a private reply, so we assign it to 1:1 chat with Alice.
|
|
||||||
assert snapshot.chat == bob_chat_alice
|
|
||||||
|
|
||||||
|
|
||||||
def test_markseen_contact_request(acfactory):
|
def test_markseen_contact_request(acfactory):
|
||||||
|
|||||||
@@ -815,15 +815,6 @@ async fn test_self_talk() -> Result<()> {
|
|||||||
assert!(msg.get_showpadlock());
|
assert!(msg.get_showpadlock());
|
||||||
|
|
||||||
let sent_msg = t.pop_sent_msg().await;
|
let sent_msg = t.pop_sent_msg().await;
|
||||||
let payload = sent_msg.payload();
|
|
||||||
// Make sure the `To` field contains the address and not
|
|
||||||
// "undisclosed recipients".
|
|
||||||
// Otherwise Delta Chat core <1.153.0 assigns the message
|
|
||||||
// to the trash chat.
|
|
||||||
assert_eq!(
|
|
||||||
payload.match_indices("To: <alice@example.org>\r\n").count(),
|
|
||||||
1
|
|
||||||
);
|
|
||||||
|
|
||||||
let t2 = TestContext::new_alice().await;
|
let t2 = TestContext::new_alice().await;
|
||||||
t2.recv_msg(&sent_msg).await;
|
t2.recv_msg(&sent_msg).await;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use data_encoding::BASE32_NOPAD;
|
|||||||
use deltachat_contact_tools::sanitize_bidi_characters;
|
use deltachat_contact_tools::sanitize_bidi_characters;
|
||||||
use iroh_gossip::proto::TopicId;
|
use iroh_gossip::proto::TopicId;
|
||||||
use mail_builder::headers::HeaderType;
|
use mail_builder::headers::HeaderType;
|
||||||
use mail_builder::headers::address::{Address, EmailAddress};
|
use mail_builder::headers::address::Address;
|
||||||
use mail_builder::mime::MimePart;
|
use mail_builder::mime::MimePart;
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
|
|
||||||
@@ -993,24 +993,7 @@ impl MimeFactory {
|
|||||||
} else if header_name == "to" {
|
} else if header_name == "to" {
|
||||||
protected_headers.push(header.clone());
|
protected_headers.push(header.clone());
|
||||||
if is_encrypted {
|
if is_encrypted {
|
||||||
let mut to_without_names = to
|
unprotected_headers.push(("To", hidden_recipients().into()));
|
||||||
.clone()
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(|header| match header {
|
|
||||||
Address::Address(mb) => Some(Address::Address(EmailAddress {
|
|
||||||
name: None,
|
|
||||||
email: mb.email,
|
|
||||||
})),
|
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
if to_without_names.is_empty() {
|
|
||||||
to_without_names.push(hidden_recipients());
|
|
||||||
}
|
|
||||||
unprotected_headers.push((
|
|
||||||
original_header_name,
|
|
||||||
Address::new_list(to_without_names).into(),
|
|
||||||
));
|
|
||||||
} else {
|
} else {
|
||||||
unprotected_headers.push(header.clone());
|
unprotected_headers.push(header.clone());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -750,8 +750,6 @@ async fn test_remove_member_bcc() -> Result<()> {
|
|||||||
|
|
||||||
let bob_id = alice.add_or_lookup_contact_id(bob).await;
|
let bob_id = alice.add_or_lookup_contact_id(bob).await;
|
||||||
let charlie_id = alice.add_or_lookup_contact_id(charlie).await;
|
let charlie_id = alice.add_or_lookup_contact_id(charlie).await;
|
||||||
let charlie_contact = Contact::get_by_id(alice, charlie_id).await?;
|
|
||||||
let charlie_addr = charlie_contact.get_addr();
|
|
||||||
|
|
||||||
let alice_chat_id = create_group(alice, "foo").await?;
|
let alice_chat_id = create_group(alice, "foo").await?;
|
||||||
add_contact_to_chat(alice, alice_chat_id, bob_id).await?;
|
add_contact_to_chat(alice, alice_chat_id, bob_id).await?;
|
||||||
@@ -770,11 +768,11 @@ async fn test_remove_member_bcc() -> Result<()> {
|
|||||||
for to_addr in to.iter() {
|
for to_addr in to.iter() {
|
||||||
match to_addr {
|
match to_addr {
|
||||||
mailparse::MailAddr::Single(info) => {
|
mailparse::MailAddr::Single(info) => {
|
||||||
// Addresses should be of existing members (Alice and Bob) and not Charlie.
|
panic!("Single addresses are not expected here: {info:?}");
|
||||||
assert_ne!(info.addr, charlie_addr);
|
|
||||||
}
|
}
|
||||||
mailparse::MailAddr::Group(_) => {
|
mailparse::MailAddr::Group(info) => {
|
||||||
panic!("Group addresses are not expected here");
|
assert_eq!(info.group_name, "hidden-recipients");
|
||||||
|
assert_eq!(info.addrs, []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user