diff --git a/deltachat-repl/src/cmdline.rs b/deltachat-repl/src/cmdline.rs index 85bf79395..542e7854f 100644 --- a/deltachat-repl/src/cmdline.rs +++ b/deltachat-repl/src/cmdline.rs @@ -560,7 +560,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu for i in (0..cnt).rev() { let chat = Chat::load_from_db(&context, chatlist.get_chat_id(i)?).await?; println!( - "{}#{}: {} [{} fresh] {}{}{}{}", + "{}#{}: {} [{} fresh] {}{}{}", chat_prefix(&chat), chat.get_id(), chat.get_name(), @@ -571,7 +571,6 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu ChatVisibility::Archived => "📦", ChatVisibility::Pinned => "📌", }, - if chat.is_protected() { "🛡️" } else { "" }, if chat.is_contact_request() { "🆕" } else { @@ -686,7 +685,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu format!("{} member(s)", members.len()) }; println!( - "{}#{}: {} [{}]{}{}{} {}", + "{}#{}: {} [{}]{}{}{}", chat_prefix(sel_chat), sel_chat.get_id(), sel_chat.get_name(), @@ -704,11 +703,6 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu }, _ => "".to_string(), }, - if sel_chat.is_protected() { - "🛡️" - } else { - "" - }, ); log_msglist(&context, &msglist).await?; if let Some(draft) = sel_chat.get_id().get_draft(&context).await? { diff --git a/src/chat.rs b/src/chat.rs index 2626adc48..5032aea5c 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1219,16 +1219,6 @@ impl ChatId { Ok(()) } - /// Returns true if the chat is protected. - pub(crate) async fn is_protected(self, context: &Context) -> Result { - let protection_status = context - .sql - .query_get_value("SELECT protected FROM chats WHERE id=?", (self,)) - .await? - .unwrap_or_default(); - Ok(protection_status) - } - /// Returns the sort timestamp for a new message in the chat. /// /// `message_timestamp` should be either the message "sent" timestamp or a timestamp of the @@ -1691,53 +1681,38 @@ impl Chat { !self.is_unpromoted() } - /// Returns true if chat protection is enabled. - /// - /// UI should display a green checkmark - /// in the chat title, - /// in the chat profile title and - /// in the chatlist item - /// if chat protection is enabled. - /// UI should also display a green checkmark - /// in the contact profile - /// if 1:1 chat with this contact exists and is protected. - pub fn is_protected(&self) -> bool { - self.protected == ProtectionStatus::Protected - } - /// Returns true if the chat is encrypted. pub async fn is_encrypted(&self, context: &Context) -> Result { - let is_encrypted = self.is_protected() - || match self.typ { - Chattype::Single => { - match context - .sql - .query_row_optional( - "SELECT cc.contact_id, c.fingerprint<>'' + let is_encrypted = match self.typ { + Chattype::Single => { + match context + .sql + .query_row_optional( + "SELECT cc.contact_id, c.fingerprint<>'' FROM chats_contacts cc LEFT JOIN contacts c ON c.id=cc.contact_id WHERE cc.chat_id=? ", - (self.id,), - |row| { - let id: ContactId = row.get(0)?; - let is_key: bool = row.get(1)?; - Ok((id, is_key)) - }, - ) - .await? - { - Some((id, is_key)) => is_key || id == ContactId::DEVICE, - None => true, - } + (self.id,), + |row| { + let id: ContactId = row.get(0)?; + let is_key: bool = row.get(1)?; + Ok((id, is_key)) + }, + ) + .await? + { + Some((id, is_key)) => is_key || id == ContactId::DEVICE, + None => true, } - Chattype::Group => { - // Do not encrypt ad-hoc groups. - !self.grpid.is_empty() - } - Chattype::Mailinglist => false, - Chattype::OutBroadcast | Chattype::InBroadcast => true, - }; + } + Chattype::Group => { + // Do not encrypt ad-hoc groups. + !self.grpid.is_empty() + } + Chattype::Mailinglist => false, + Chattype::OutBroadcast | Chattype::InBroadcast => true, + }; Ok(is_encrypted) } @@ -3770,13 +3745,6 @@ pub(crate) async fn add_contact_to_chat_ex( } } else { // else continue and send status mail - if chat.is_protected() && !contact.is_verified(context).await? { - error!( - context, - "Cannot add non-bidirectionally verified contact {contact_id} to protected chat {chat_id}." - ); - return Ok(false); - } if is_contact_in_chat(context, chat_id, contact_id).await? { return Ok(false); } diff --git a/src/contact/contact_tests.rs b/src/contact/contact_tests.rs index 90e8b151b..b2f78630c 100644 --- a/src/contact/contact_tests.rs +++ b/src/contact/contact_tests.rs @@ -1,7 +1,7 @@ use deltachat_contact_tools::{addr_cmp, may_be_valid_addr}; use super::*; -use crate::chat::{Chat, ProtectionStatus, get_chat_contacts, send_text_msg}; +use crate::chat::{Chat, get_chat_contacts, send_text_msg}; use crate::chatlist::Chatlist; use crate::receive_imf::receive_imf; use crate::securejoin::get_securejoin_qr; @@ -1320,9 +1320,6 @@ async fn test_self_is_verified() -> Result<()> { assert!(contact.get_verifier_id(&alice).await?.is_none()); assert!(contact.is_key_contact()); - let chat_id = ChatId::get_for_contact(&alice, ContactId::SELF).await?; - assert!(chat_id.is_protected(&alice).await.unwrap() == ProtectionStatus::Protected); - Ok(()) } diff --git a/src/context/context_tests.rs b/src/context/context_tests.rs index 1ee945b17..03dcaf3bb 100644 --- a/src/context/context_tests.rs +++ b/src/context/context_tests.rs @@ -606,13 +606,10 @@ async fn test_draft_self_report() -> Result<()> { let msg = get_chat_msg(&alice, chat_id, 0, 1).await; assert_eq!(msg.get_info_type(), SystemMessage::ChatE2ee); - let chat = Chat::load_from_db(&alice, chat_id).await?; - assert!(chat.is_protected()); - let mut draft = chat_id.get_draft(&alice).await?.unwrap(); assert!(draft.text.starts_with("core_version")); - // Test that sending into the protected chat works: + // Test that sending into the chat works: let _sent = alice.send_msg(chat_id, &mut draft).await; Ok(()) diff --git a/src/mimefactory.rs b/src/mimefactory.rs index aae28d52d..3b9a0277a 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -1331,20 +1331,6 @@ impl MimeFactory { let command = msg.param.get_cmd(); let mut placeholdertext = None; - let send_verified_headers = match chat.typ { - Chattype::Single => true, - Chattype::Group => true, - // Mailinglists and broadcast channels can actually never be verified: - Chattype::Mailinglist => false, - Chattype::OutBroadcast | Chattype::InBroadcast => false, - }; - if chat.is_protected() && send_verified_headers { - headers.push(( - "Chat-Verified", - mail_builder::headers::raw::Raw::new("1").into(), - )); - } - if chat.typ == Chattype::Group { // Send group ID unless it is an ad hoc group that has no ID. if !chat.grpid.is_empty() { diff --git a/src/securejoin/bob.rs b/src/securejoin/bob.rs index 28d383ed3..ca33c4d13 100644 --- a/src/securejoin/bob.rs +++ b/src/securejoin/bob.rs @@ -4,7 +4,7 @@ use anyhow::{Context as _, Result}; use super::HandshakeMessage; use super::qrinvite::QrInvite; -use crate::chat::{self, ChatId, ProtectionStatus, is_contact_in_chat}; +use crate::chat::{self, ChatId, is_contact_in_chat}; use crate::constants::{Blocked, Chattype}; use crate::contact::Origin; use crate::context::Context; @@ -113,21 +113,19 @@ pub(super) async fn start_protocol(context: &Context, invite: QrInvite) -> Resul let ts_sort = chat_id .calc_sort_timestamp(context, 0, sort_to_bottom, received, incoming) .await?; - if chat_id.is_protected(context).await? == ProtectionStatus::Unprotected { - let ts_start = time(); - chat::add_info_msg_with_cmd( - context, - chat_id, - &stock_str::securejoin_wait(context).await, - SystemMessage::SecurejoinWait, - ts_sort, - Some(ts_start), - None, - None, - None, - ) - .await?; - } + let ts_start = time(); + chat::add_info_msg_with_cmd( + context, + chat_id, + &stock_str::securejoin_wait(context).await, + SystemMessage::SecurejoinWait, + ts_sort, + Some(ts_start), + None, + None, + None, + ) + .await?; Ok(chat_id) } } diff --git a/src/test_utils.rs b/src/test_utils.rs index bbfc381a8..5b68de1a5 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -1013,7 +1013,7 @@ impl TestContext { }; writeln!( res, - "{}#{}: {} [{}]{}{}{} {}", + "{}#{}: {} [{}]{}{}{}", sel_chat.typ, sel_chat.get_id(), sel_chat.get_name(), @@ -1031,11 +1031,6 @@ impl TestContext { }, _ => "".to_string(), }, - if sel_chat.is_protected() { - "🛡️" - } else { - "" - }, ) .unwrap(); diff --git a/src/tests/verified_chats.rs b/src/tests/verified_chats.rs index 366388cc4..c120d73ba 100644 --- a/src/tests/verified_chats.rs +++ b/src/tests/verified_chats.rs @@ -129,19 +129,12 @@ async fn test_create_verified_oneonone_chat() -> Result<()> { tcm.send_recv(&fiona_new, &alice, "I have a new device") .await; - // Alice gets a new unprotected chat with new Fiona contact. + // Alice gets a new chat with new Fiona contact. { let chat = alice.get_chat(&fiona_new).await; - assert!(!chat.is_protected()); let msg = get_chat_msg(&alice, chat.id, 1, E2EE_INFO_MSGS + 1).await; assert_eq!(msg.text, "I have a new device"); - - // After recreating the chat, it should still be unprotected - chat.id.delete(&alice).await?; - - let chat = alice.create_chat(&fiona_new).await; - assert!(!chat.is_protected()); } Ok(()) @@ -175,41 +168,6 @@ async fn test_missing_key_reexecute_securejoin() -> Result<()> { Ok(()) } -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn test_create_unverified_oneonone_chat() -> Result<()> { - let mut tcm = TestContextManager::new(); - let alice = tcm.alice().await; - let bob = tcm.bob().await; - - // A chat with an unknown contact should be created unprotected - let chat = alice.create_chat(&bob).await; - assert!(!chat.is_protected()); - - receive_imf( - &alice, - b"From: Bob \n\ - To: alice@example.org\n\ - Message-ID: <1234-2@example.org>\n\ - \n\ - hello\n", - false, - ) - .await?; - - chat.id.delete(&alice).await.unwrap(); - // Now Bob is a known contact, new chats should still be created unprotected - let chat = alice.create_chat(&bob).await; - assert!(!chat.is_protected()); - - tcm.send_recv(&bob, &alice, "hi").await; - chat.id.delete(&alice).await.unwrap(); - // Now we have a public key, new chats should still be created unprotected - let chat = alice.create_chat(&bob).await; - assert!(!chat.is_protected()); - - Ok(()) -} - /// Tests that receiving unencrypted message /// does not disable protection of 1:1 chat. /// @@ -223,7 +181,6 @@ async fn test_degrade_verified_oneonone_chat() -> Result<()> { mark_as_verified(&alice, &bob).await; let alice_chat = alice.create_chat(&bob).await; - assert!(alice_chat.is_protected()); receive_imf( &alice, @@ -484,8 +441,6 @@ async fn test_message_from_old_dc_setup() -> Result<()> { // The outdated Bob's Autocrypt header isn't applied // and the message goes to another chat, so the verification preserves. assert!(contact.is_verified(alice).await.unwrap()); - let chat = alice.get_chat(bob).await; - assert!(chat.is_protected()); Ok(()) } @@ -587,9 +542,9 @@ async fn test_verified_member_added_reordering() -> Result<()> { // "Member added" message, so unverified group is created. let fiona_received_message = fiona.recv_msg(&bob_sent_message).await; let fiona_chat = Chat::load_from_db(fiona, fiona_received_message.chat_id).await?; + assert!(!fiona_chat.can_send(fiona).await?); assert_eq!(fiona_received_message.get_text(), "Hi"); - assert_eq!(fiona_chat.is_protected(), false); // Fiona receives late "Member added" message // and the chat becomes protected. diff --git a/test-data/golden/chat_test_parallel_member_remove b/test-data/golden/chat_test_parallel_member_remove index c71bcf0d5..1e4e17d3d 100644 --- a/test-data/golden/chat_test_parallel_member_remove +++ b/test-data/golden/chat_test_parallel_member_remove @@ -1,4 +1,4 @@ -Group#Chat#10: Group chat [3 member(s)] +Group#Chat#10: Group chat [3 member(s)] -------------------------------------------------------------------------------- Msg#10: info (Contact#Contact#Info): Messages are end-to-end encrypted. [NOTICED][INFO] Msg#11🔒: (Contact#Contact#10): Hi! I created a group. [FRESH] diff --git a/test-data/golden/receive_imf_delayed_removal_is_ignored b/test-data/golden/receive_imf_delayed_removal_is_ignored index edcf03c1e..1e8363ba7 100644 --- a/test-data/golden/receive_imf_delayed_removal_is_ignored +++ b/test-data/golden/receive_imf_delayed_removal_is_ignored @@ -1,4 +1,4 @@ -Group#Chat#10: Group [5 member(s)] +Group#Chat#10: Group [5 member(s)] -------------------------------------------------------------------------------- Msg#10: info (Contact#Contact#Info): Messages are end-to-end encrypted. [NOTICED][INFO] Msg#11🔒: Me (Contact#Contact#Self): populate √ diff --git a/test-data/golden/receive_imf_older_message_from_2nd_device b/test-data/golden/receive_imf_older_message_from_2nd_device index abc38ad33..4d036f98e 100644 --- a/test-data/golden/receive_imf_older_message_from_2nd_device +++ b/test-data/golden/receive_imf_older_message_from_2nd_device @@ -1,4 +1,4 @@ -Single#Chat#10: bob@example.net [bob@example.net] Icon: 4138c52e5bc1c576cda7dd44d088c07.png +Single#Chat#10: bob@example.net [bob@example.net] Icon: 4138c52e5bc1c576cda7dd44d088c07.png -------------------------------------------------------------------------------- Msg#10: Me (Contact#Contact#Self): We share this account √ Msg#11: Me (Contact#Contact#Self): I'm Alice too √ diff --git a/test-data/golden/test_old_message_5 b/test-data/golden/test_old_message_5 index 624838a43..9a847dce0 100644 --- a/test-data/golden/test_old_message_5 +++ b/test-data/golden/test_old_message_5 @@ -1,4 +1,4 @@ -Single#Chat#10: Bob [bob@example.net] Icon: 4138c52e5bc1c576cda7dd44d088c07.png +Single#Chat#10: Bob [bob@example.net] Icon: 4138c52e5bc1c576cda7dd44d088c07.png -------------------------------------------------------------------------------- Msg#10: Me (Contact#Contact#Self): Happy birthday, Bob! √ Msg#11: (Contact#Contact#10): Happy birthday to me, Alice! [FRESH] diff --git a/test-data/golden/test_outgoing_encrypted_msg b/test-data/golden/test_outgoing_encrypted_msg index 1ffb0d799..cf7625803 100644 --- a/test-data/golden/test_outgoing_encrypted_msg +++ b/test-data/golden/test_outgoing_encrypted_msg @@ -1,4 +1,4 @@ -Single#Chat#10: bob@example.net [KEY bob@example.net] 🛡️ +Single#Chat#10: bob@example.net [KEY bob@example.net] -------------------------------------------------------------------------------- Msg#10: info (Contact#Contact#Info): Messages are end-to-end encrypted. [NOTICED][INFO] Msg#11🔒: Me (Contact#Contact#Self): Test – This is encrypted, signed, and has an Autocrypt Header without prefer-encrypt=mutual. √ diff --git a/test-data/golden/test_outgoing_mua_msg b/test-data/golden/test_outgoing_mua_msg index 5d4a0f2ee..db73265bb 100644 --- a/test-data/golden/test_outgoing_mua_msg +++ b/test-data/golden/test_outgoing_mua_msg @@ -1,4 +1,4 @@ -Single#Chat#11: bob@example.net [bob@example.net] Icon: 4138c52e5bc1c576cda7dd44d088c07.png +Single#Chat#11: bob@example.net [bob@example.net] Icon: 4138c52e5bc1c576cda7dd44d088c07.png -------------------------------------------------------------------------------- Msg#12: Me (Contact#Contact#Self): One classical MUA message √ -------------------------------------------------------------------------------- diff --git a/test-data/golden/test_outgoing_mua_msg_pgp b/test-data/golden/test_outgoing_mua_msg_pgp index f95ae0430..b71ee0873 100644 --- a/test-data/golden/test_outgoing_mua_msg_pgp +++ b/test-data/golden/test_outgoing_mua_msg_pgp @@ -1,4 +1,4 @@ -Single#Chat#10: bob@example.net [KEY bob@example.net] 🛡️ +Single#Chat#10: bob@example.net [KEY bob@example.net] -------------------------------------------------------------------------------- Msg#10: info (Contact#Contact#Info): Messages are end-to-end encrypted. [NOTICED][INFO] Msg#11🔒: (Contact#Contact#10): Heyho from DC [FRESH] diff --git a/test-data/golden/two_group_securejoins b/test-data/golden/two_group_securejoins index 34f8f68e9..fe3f5efc1 100644 --- a/test-data/golden/two_group_securejoins +++ b/test-data/golden/two_group_securejoins @@ -1,4 +1,4 @@ -Group#Chat#11: Group [3 member(s)] +Group#Chat#11: Group [3 member(s)] -------------------------------------------------------------------------------- Msg#13: info (Contact#Contact#Info): alice@example.org invited you to join this group. diff --git a/test-data/golden/verified_chats_editor_reordering b/test-data/golden/verified_chats_editor_reordering index adbff7ecc..15f88d602 100644 --- a/test-data/golden/verified_chats_editor_reordering +++ b/test-data/golden/verified_chats_editor_reordering @@ -1,4 +1,4 @@ -Group#Chat#11: Group [3 member(s)] +Group#Chat#11: Group [3 member(s)] -------------------------------------------------------------------------------- Msg#13: info (Contact#Contact#Info): alice@example.org invited you to join this group.