From 63596a4940cea5310d8ae9b324b49d3a5dd11023 Mon Sep 17 00:00:00 2001 From: link2xt Date: Thu, 18 Dec 2025 20:29:11 +0000 Subject: [PATCH] feat: remove show_emails config --- deltachat-ffi/deltachat.h | 18 +---- .../tests/test_multitransport.py | 18 ----- src/chat/chat_tests.rs | 6 -- src/config.rs | 10 +-- src/config/config_tests.rs | 7 -- src/constants.rs | 23 ------- src/context.rs | 4 -- src/html.rs | 11 ---- src/imap.rs | 2 +- src/message.rs | 1 - src/mimefactory/mimefactory_tests.rs | 5 -- src/receive_imf.rs | 29 +------- src/receive_imf/receive_imf_tests.rs | 66 +------------------ src/sql/migrations.rs | 7 +- src/test_utils.rs | 3 +- 15 files changed, 10 insertions(+), 200 deletions(-) diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 783ad4f6c..08ea78d19 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -408,12 +408,6 @@ char* dc_get_blobdir (const dc_context_t* context); * 1=send a copy of outgoing messages to self (default). * Sending messages to self is needed for a proper multi-account setup, * however, on the other hand, may lead to unwanted notifications in non-delta clients. - * - `show_emails` = DC_SHOW_EMAILS_OFF (0)= - * show direct replies to chats only, - * DC_SHOW_EMAILS_ACCEPTED_CONTACTS (1)= - * also show all mails of confirmed contacts, - * DC_SHOW_EMAILS_ALL (2)= - * also show mails of unconfirmed contacts (default). * - `delete_device_after` = 0=do not delete messages from device automatically (default), * >=1=seconds, after which messages are deleted automatically from the device. * Messages in the "saved messages" chat (see dc_chat_is_self_talk()) are skipped. @@ -422,8 +416,7 @@ char* dc_get_blobdir (const dc_context_t* context); * - `delete_server_after` = 0=do not delete messages from server automatically (default), * 1=delete messages directly after receiving from server, mvbox is skipped. * >1=seconds, after which messages are deleted automatically from the server, mvbox is used as defined. - * "Saved messages" are deleted from the server as well as - * e-mails matching the `show_emails` settings above, the UI should clearly point that out. + * "Saved messages" are deleted from the server as well as emails, the UI should clearly point that out. * See also dc_estimate_deletion_cnt(). * - `media_quality` = DC_MEDIA_QUALITY_BALANCED (0) = * good outgoing images/videos/voice quality at reasonable sizes (default) @@ -1479,7 +1472,6 @@ dc_chatlist_t* dc_get_similar_chatlist (dc_context_t* context, uint32_t ch * @param from_server 1=Estimate deletion count for server, 0=Estimate deletion count for device * @param seconds Count messages older than the given number of seconds. * @return Number of messages that are older than the given number of seconds. - * This includes e-mails downloaded due to the `show_emails` option. * Messages in the "saved messages" folder are not counted as they will not be deleted automatically. */ int dc_estimate_deletion_cnt (dc_context_t* context, int from_server, int64_t seconds); @@ -6681,14 +6673,6 @@ void dc_event_unref(dc_event_t* event); #define DC_EVENT_DATA2_IS_STRING(e) ((e)==DC_EVENT_CONFIGURE_PROGRESS || (e)==DC_EVENT_IMEX_FILE_WRITTEN || ((e)>=100 && (e)<=499)) -/* - * Values for dc_get|set_config("show_emails") - */ -#define DC_SHOW_EMAILS_OFF 0 -#define DC_SHOW_EMAILS_ACCEPTED_CONTACTS 1 -#define DC_SHOW_EMAILS_ALL 2 - - /* * Values for dc_get|set_config("media_quality") */ diff --git a/deltachat-rpc-client/tests/test_multitransport.py b/deltachat-rpc-client/tests/test_multitransport.py index 2e52cb0d5..e2605854a 100644 --- a/deltachat-rpc-client/tests/test_multitransport.py +++ b/deltachat-rpc-client/tests/test_multitransport.py @@ -9,8 +9,6 @@ def test_add_second_address(acfactory) -> None: account = acfactory.new_configured_account() assert len(account.list_transports()) == 1 - assert account.get_config("show_emails") == "2" - qr = acfactory.get_account_qr() account.add_transport_from_qr(qr) assert len(account.list_transports()) == 2 @@ -28,22 +26,6 @@ def test_add_second_address(acfactory) -> None: account.delete_transport(second_addr) assert len(account.list_transports()) == 2 - # show_emails does not matter for multi-relay, can be set to anything - account.set_config("show_emails", "0") - - -def test_second_transport_without_classic_emails(acfactory) -> None: - """Test that second transport can be configured if classic emails are not fetched.""" - account = acfactory.new_configured_account() - assert len(account.list_transports()) == 1 - - assert account.get_config("show_emails") == "2" - - qr = acfactory.get_account_qr() - account.set_config("show_emails", "0") - - account.add_transport_from_qr(qr) - def test_change_address(acfactory) -> None: """Test Alice configuring a second transport and setting it as a primary one.""" diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs index 3e15245b1..793db819b 100644 --- a/src/chat/chat_tests.rs +++ b/src/chat/chat_tests.rs @@ -2032,12 +2032,6 @@ async fn test_classic_email_chat() -> Result<()> { let msgs = get_chat_msgs(&alice, chat_id).await?; assert_eq!(msgs.len(), 1); - // Alice disables receiving classic emails. - alice - .set_config(Config::ShowEmails, Some("0")) - .await - .unwrap(); - // Already received classic email should still be in the chat. assert_eq!(chat_id.get_fresh_msg_cnt(&alice).await?, 1); diff --git a/src/config.rs b/src/config.rs index 7599ee44a..dfba017ea 100644 --- a/src/config.rs +++ b/src/config.rs @@ -190,10 +190,6 @@ pub enum Config { #[strum(props(default = "1"))] MdnsEnabled, - /// Whether to show classic emails or only chat messages. - #[strum(props(default = "2"))] // also change ShowEmails.default() on changes - ShowEmails, - /// Quality of the media files to send. #[strum(props(default = "0"))] // also change MediaQuality.default() on changes MediaQuality, @@ -514,11 +510,7 @@ impl Config { pub(crate) fn is_synced(&self) -> bool { matches!( self, - Self::Displayname - | Self::MdnsEnabled - | Self::ShowEmails - | Self::Selfavatar - | Self::Selfstatus, + Self::Displayname | Self::MdnsEnabled | Self::Selfavatar | Self::Selfstatus, ) } diff --git a/src/config/config_tests.rs b/src/config/config_tests.rs index a154a1b95..af041385e 100644 --- a/src/config/config_tests.rs +++ b/src/config/config_tests.rs @@ -196,13 +196,6 @@ async fn test_sync() -> Result<()> { sync(&alice0, &alice1).await; assert_eq!(alice1.get_config_bool(Config::MdnsEnabled).await?, false); - { - let val = alice0.get_config_bool(Config::ShowEmails).await?; - alice0.set_config_bool(Config::ShowEmails, !val).await?; - sync(&alice0, &alice1).await; - assert_eq!(alice1.get_config_bool(Config::ShowEmails).await?, !val); - } - // `Config::SyncMsgs` mustn't be synced. alice0.set_config_bool(Config::SyncMsgs, false).await?; alice0.set_config_bool(Config::SyncMsgs, true).await?; diff --git a/src/constants.rs b/src/constants.rs index fe3a50028..9b109c0f5 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -36,17 +36,6 @@ pub enum Blocked { Request = 2, } -#[derive( - Debug, Default, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql, -)] -#[repr(u8)] -pub enum ShowEmails { - Off = 0, - AcceptedContacts = 1, - #[default] // also change Config.ShowEmails props(default) on changes - All = 2, -} - #[derive( Debug, Default, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql, )] @@ -262,18 +251,6 @@ mod tests { assert_eq!(Chattype::OutBroadcast, Chattype::from_i32(160).unwrap()); } - #[test] - fn test_showemails_values() { - // values may be written to disk and must not change - assert_eq!(ShowEmails::All, ShowEmails::default()); - assert_eq!(ShowEmails::Off, ShowEmails::from_i32(0).unwrap()); - assert_eq!( - ShowEmails::AcceptedContacts, - ShowEmails::from_i32(1).unwrap() - ); - assert_eq!(ShowEmails::All, ShowEmails::from_i32(2).unwrap()); - } - #[test] fn test_blocked_values() { // values may be written to disk and must not change diff --git a/src/context.rs b/src/context.rs index fe148b4c6..fadd30bb2 100644 --- a/src/context.rs +++ b/src/context.rs @@ -946,10 +946,6 @@ impl Context { } res.insert("secondary_addrs", secondary_addrs); - res.insert( - "show_emails", - self.get_config_int(Config::ShowEmails).await?.to_string(), - ); res.insert( "who_can_call_me", self.get_config_int(Config::WhoCanCallMe).await?.to_string(), diff --git a/src/html.rs b/src/html.rs index dd7ada62e..bc4e4bfbc 100644 --- a/src/html.rs +++ b/src/html.rs @@ -287,7 +287,6 @@ impl MsgId { mod tests { use super::*; use crate::chat::{self, Chat, forward_msgs, save_msgs}; - use crate::config::Config; use crate::constants; use crate::contact::ContactId; use crate::message::{MessengerMessage, Viewtype}; @@ -555,13 +554,7 @@ test some special html-characters as < > and & but also " and &#x async fn test_html_forwarding_encrypted() { let mut tcm = TestContextManager::new(); // Alice receives a non-delta html-message - // (`ShowEmails=AcceptedContacts` lets Alice actually receive non-delta messages for known - // contacts, the contact is marked as known by creating a chat using `chat_with_contact()`) let alice = &tcm.alice().await; - alice - .set_config(Config::ShowEmails, Some("1")) - .await - .unwrap(); let chat = alice .create_chat_with_contact("", "sender@testrun.org") .await; @@ -579,10 +572,6 @@ test some special html-characters as < > and & but also " and &#x // receive the message on another device let alice = &tcm.alice().await; - alice - .set_config(Config::ShowEmails, Some("0")) - .await - .unwrap(); let msg = alice.recv_msg(&msg).await; assert_eq!(msg.chat_id, alice.get_self_chat().await.id); assert_eq!(msg.get_from_id(), ContactId::SELF); diff --git a/src/imap.rs b/src/imap.rs index 3f487ba78..892253bc2 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -2001,7 +2001,7 @@ pub(crate) async fn prefetch_should_download( return Ok(false); } - let should_download = (!blocked_contact) || maybe_ndn; + let should_download = !blocked_contact || maybe_ndn; Ok(should_download) } diff --git a/src/message.rs b/src/message.rs index 27a8e97f8..1a0d134ac 100644 --- a/src/message.rs +++ b/src/message.rs @@ -2117,7 +2117,6 @@ pub async fn get_request_msg_cnt(context: &Context) -> usize { /// Count messages older than the given number of `seconds`. /// /// Returns the number of messages that are older than the given number of seconds. -/// This includes e-mails downloaded due to the `show_emails` option. /// Messages in the "saved messages" folder are not counted as they will not be deleted automatically. #[expect(clippy::arithmetic_side_effects)] pub async fn estimate_deletion_cnt( diff --git a/src/mimefactory/mimefactory_tests.rs b/src/mimefactory/mimefactory_tests.rs index fe03953a9..90de2d27a 100644 --- a/src/mimefactory/mimefactory_tests.rs +++ b/src/mimefactory/mimefactory_tests.rs @@ -506,11 +506,6 @@ async fn msg_to_subject_str_inner( // Creates a `Message` that replies "Hi" to the incoming email in `imf_raw`. async fn incoming_msg_to_reply_msg(imf_raw: &[u8], context: &Context) -> Message { - context - .set_config(Config::ShowEmails, Some("2")) - .await - .unwrap(); - receive_imf(context, imf_raw, false).await.unwrap(); let chats = Chatlist::try_load(context, 0, None, None).await.unwrap(); diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 0415d76b4..443c9dc37 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -11,14 +11,13 @@ use deltachat_contact_tools::{ sanitize_single_line, }; use mailparse::SingleInfo; -use num_traits::FromPrimitive; use regex::Regex; use crate::chat::{ self, Chat, ChatId, ChatIdBlocked, ChatVisibility, is_contact_in_chat, save_broadcast_secret, }; use crate::config::Config; -use crate::constants::{self, Blocked, Chattype, DC_CHAT_ID_TRASH, EDITED_PREFIX, ShowEmails}; +use crate::constants::{self, Blocked, Chattype, DC_CHAT_ID_TRASH, EDITED_PREFIX}; use crate::contact::{self, Contact, ContactId, Origin, mark_contact_id_as_verified}; use crate::context::Context; use crate::debug_logging::maybe_set_logging_xdc_inner; @@ -720,20 +719,8 @@ pub(crate) async fn receive_imf_inner( MessengerMessage::No }; - let show_emails = ShowEmails::from_i32(context.get_config_int(Config::ShowEmails).await?) - .unwrap_or_default(); - let allow_creation = if mime_parser.decryption_error.is_some() { false - } else if is_dc_message == MessengerMessage::No - && !context.get_config_bool(Config::IsChatmail).await? - { - // the message is a classic email in a classic profile - // (in chatmail profiles, we always show all messages, because shared dc-mua usage is not supported) - match show_emails { - ShowEmails::Off | ShowEmails::AcceptedContacts => false, - ShowEmails::All => true, - } } else { !mime_parser.parts.iter().all(|part| part.is_reaction) }; @@ -1254,20 +1241,6 @@ async fn decide_chat_assignment( } info!(context, "Outgoing undecryptable message (TRASH)."); true - } else if mime_parser.is_system_message != SystemMessage::AutocryptSetupMessage - && !mime_parser.has_chat_version() - && parent_message - .as_ref() - .is_none_or(|p| p.is_dc_message == MessengerMessage::No) - && !context.get_config_bool(Config::IsChatmail).await? - && ShowEmails::from_i32(context.get_config_int(Config::ShowEmails).await?) - .unwrap_or_default() - == ShowEmails::Off - { - info!(context, "Classical email not shown (TRASH)."); - // the message is a classic email in a classic profile - // (in chatmail profiles, we always show all messages, because shared dc-mua usage is not supported) - true } else if mime_parser .get_header(HeaderDef::XMozillaDraftInfo) .is_some() diff --git a/src/receive_imf/receive_imf_tests.rs b/src/receive_imf/receive_imf_tests.rs index bb1dc26b8..f36295717 100644 --- a/src/receive_imf/receive_imf_tests.rs +++ b/src/receive_imf/receive_imf_tests.rs @@ -16,7 +16,7 @@ use crate::imex::{ImexMode, imex}; use crate::key; use crate::securejoin::get_securejoin_qr; use crate::test_utils::{ - E2EE_INFO_MSGS, TestContext, TestContextManager, alice_keypair, get_chat_msg, mark_as_verified, + TestContext, TestContextManager, alice_keypair, get_chat_msg, mark_as_verified, }; use crate::tools::{SystemTime, time}; @@ -78,9 +78,8 @@ static GRP_MAIL: &[u8] = hello\n"; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn test_adhoc_group_show_chats_only() { +async fn test_adhoc_group_is_shown() { let t = TestContext::new_alice().await; - t.set_config(Config::ShowEmails, Some("0")).await.unwrap(); let chats = Chatlist::try_load(&t, 0, None, None).await.unwrap(); assert_eq!(chats.len(), 0); @@ -95,66 +94,12 @@ async fn test_adhoc_group_show_chats_only() { receive_imf(&t, GRP_MAIL, false).await.unwrap(); let chats = Chatlist::try_load(&t, 0, None, None).await.unwrap(); - assert_eq!(chats.len(), 1); -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn test_adhoc_group_show_accepted_contact_unknown() { - let t = TestContext::new_alice().await; - t.set_config(Config::ShowEmails, Some("1")).await.unwrap(); - receive_imf(&t, GRP_MAIL, false).await.unwrap(); - - // adhoc-group with unknown contacts with show_emails=accepted is ignored for unknown contacts - let chats = Chatlist::try_load(&t, 0, None, None).await.unwrap(); - assert_eq!(chats.len(), 0); -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn test_adhoc_group_outgoing_show_accepted_contact_unaccepted() -> Result<()> { - let mut tcm = TestContextManager::new(); - let alice = &tcm.alice().await; - let bob = &tcm.bob().await; - bob.set_config( - Config::ShowEmails, - Some(&ShowEmails::AcceptedContacts.to_string()), - ) - .await?; - tcm.send_recv(alice, bob, "hi").await; - receive_imf( - bob, - b"From: bob@example.net\n\ - To: alice@example.org, claire@example.com\n\ - Message-ID: <3333@example.net>\n\ - Date: Sun, 22 Mar 2020 22:37:57 +0000\n\ - \n\ - hello\n", - false, - ) - .await?; - let chats = Chatlist::try_load(bob, 0, None, None).await?; - assert_eq!(chats.len(), 1); - let chat_id = chats.get_chat_id(0)?; - assert_eq!(chat_id.get_msg_cnt(bob).await?, E2EE_INFO_MSGS + 1); - Ok(()) -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn test_adhoc_group_show_accepted_contact_known() { - let t = TestContext::new_alice().await; - t.set_config(Config::ShowEmails, Some("1")).await.unwrap(); - Contact::create(&t, "Bob", "bob@example.com").await.unwrap(); - receive_imf(&t, GRP_MAIL, false).await.unwrap(); - - // adhoc-group with known contacts with show_emails=accepted is still ignored for known contacts - // (and existent chat is required) - let chats = Chatlist::try_load(&t, 0, None, None).await.unwrap(); - assert_eq!(chats.len(), 0); + assert_eq!(chats.len(), 2); } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_adhoc_group_show_accepted_contact_accepted() { let t = TestContext::new_alice().await; - t.set_config(Config::ShowEmails, Some("1")).await.unwrap(); // accept Bob by accepting a delta-message from Bob receive_imf(&t, MSGRMSG, false).await.unwrap(); @@ -190,7 +135,6 @@ async fn test_adhoc_group_show_accepted_contact_accepted() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_adhoc_group_show_all() { let t = TestContext::new_alice().await; - assert_eq!(t.get_config_int(Config::ShowEmails).await.unwrap(), 2); receive_imf(&t, GRP_MAIL, false).await.unwrap(); // adhoc-group with unknown contacts with show_emails=all will show up in a single chat @@ -816,10 +760,6 @@ async fn test_concat_multiple_ndns() -> Result<()> { } async fn load_imf_email(context: &Context, imf_raw: &[u8]) -> Message { - context - .set_config(Config::ShowEmails, Some("2")) - .await - .unwrap(); let received_msg = receive_imf(context, imf_raw, false) .await .expect("receive_imf failure") diff --git a/src/sql/migrations.rs b/src/sql/migrations.rs index b52b82c9c..576b148d4 100644 --- a/src/sql/migrations.rs +++ b/src/sql/migrations.rs @@ -12,7 +12,6 @@ use rusqlite::OptionalExtension; use crate::config::Config; use crate::configure::EnteredLoginParam; -use crate::constants::ShowEmails; use crate::context::Context; use crate::key::DcKey; use crate::log::warn; @@ -975,8 +974,7 @@ ALTER TABLE msgs ADD COLUMN mime_references TEXT;"#, // keep this default and use DC_SHOW_EMAILS_NO // only for new installations if exists_before_update { - sql.set_raw_config_int("show_emails", ShowEmails::All as i32) - .await?; + sql.set_raw_config_int("show_emails", 2).await?; } sql.set_db_version(50).await?; } @@ -1457,8 +1455,7 @@ CREATE INDEX smtp_messageid ON imap(rfc724_mid); } if dbversion < 98 { if exists_before_update && sql.get_raw_config_int("show_emails").await?.is_none() { - sql.set_raw_config_int("show_emails", ShowEmails::Off as i32) - .await?; + sql.set_raw_config_int("show_emails", 0).await?; } sql.set_db_version(98).await?; } diff --git a/src/test_utils.rs b/src/test_utils.rs index a365630b4..5252ada38 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -793,8 +793,7 @@ ORDER BY id" let chat_msgs = chat::get_chat_msgs(self, received.chat_id).await.unwrap(); assert!( chat_msgs.contains(&ChatItem::Message { msg_id: msg.id }), - "received message is not shown in chat, maybe it's hidden (you may have \ - to call set_config(Config::ShowEmails, Some(\"2\")).await)" + "received message is not shown in chat, maybe it's hidden" ); msg