From cd6d181bbc7d92c5ee0414f40ecf363d312a9ba3 Mon Sep 17 00:00:00 2001 From: bjoern Date: Sat, 24 Sep 2022 21:54:06 +0200 Subject: [PATCH] enable `BccSelf` by default (#3612) * enable `BccSelf` by default enabling `BccSelf` improves user experience as it is easier to set up another device and ppl will also see "all" messages in other user agents directly. for uncounted user problems, after diving into the issue, the resulting device was "turn on BccSelf". disabled `BccSelf` was probably the the number one single reason of user problems. main drawback of the change are potentially double notifications when using a shared account and having another mail app on the same device. however, we meanwhile do not recommend shared accounts at all, the issue is also fixable by the other mail apps (as done by K-9) and could be even regarded as a feature (you can decide which app to use for ansering). but at the end the drawback is probably much smaller than the issues reported above. * adapt tests to `BccSelf` enabled * update CHANGELOG --- CHANGELOG.md | 1 + src/chat.rs | 34 ++++++++++++++++------------------ src/config.rs | 2 +- src/webxdc.rs | 1 + 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a3ff8c6b..66deb3c6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - truncate incoming messages by lines instead of just length #3480 - emit separate `DC_EVENT_MSGS_CHANGED` for each expired message, and `DC_EVENT_WEBXDC_INSTANCE_DELETED` when a message contains a webxdc #3605 +- enable `bcc_self` by default #3612 ### Fixes diff --git a/src/chat.rs b/src/chat.rs index f2927a6b6..cbc5f0636 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -4554,26 +4554,24 @@ mod tests { } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] - async fn test_set_protection() { + async fn test_set_protection() -> Result<()> { let t = TestContext::new_alice().await; - let chat_id = create_group_chat(&t, ProtectionStatus::Unprotected, "foo") - .await - .unwrap(); - let chat = Chat::load_from_db(&t, chat_id).await.unwrap(); + t.set_config_bool(Config::BccSelf, false).await?; + let chat_id = create_group_chat(&t, ProtectionStatus::Unprotected, "foo").await?; + let chat = Chat::load_from_db(&t, chat_id).await?; assert!(!chat.is_protected()); assert!(chat.is_unpromoted()); // enable protection on unpromoted chat, the info-message is added via add_info_msg() chat_id .set_protection(&t, ProtectionStatus::Protected) - .await - .unwrap(); + .await?; - let chat = Chat::load_from_db(&t, chat_id).await.unwrap(); + let chat = Chat::load_from_db(&t, chat_id).await?; assert!(chat.is_protected()); assert!(chat.is_unpromoted()); - let msgs = get_chat_msgs(&t, chat_id, 0).await.unwrap(); + let msgs = get_chat_msgs(&t, chat_id, 0).await?; assert_eq!(msgs.len(), 1); let msg = t.get_last_msg_in(chat_id).await; @@ -4584,10 +4582,9 @@ mod tests { // disable protection again, still unpromoted chat_id .set_protection(&t, ProtectionStatus::Unprotected) - .await - .unwrap(); + .await?; - let chat = Chat::load_from_db(&t, chat_id).await.unwrap(); + let chat = Chat::load_from_db(&t, chat_id).await?; assert!(!chat.is_protected()); assert!(chat.is_unpromoted()); @@ -4597,21 +4594,20 @@ mod tests { assert_eq!(msg.get_state(), MessageState::InNoticed); // send a message, this switches to promoted state - send_text_msg(&t, chat_id, "hi!".to_string()).await.unwrap(); + send_text_msg(&t, chat_id, "hi!".to_string()).await?; - let chat = Chat::load_from_db(&t, chat_id).await.unwrap(); + let chat = Chat::load_from_db(&t, chat_id).await?; assert!(!chat.is_protected()); assert!(!chat.is_unpromoted()); - let msgs = get_chat_msgs(&t, chat_id, 0).await.unwrap(); + let msgs = get_chat_msgs(&t, chat_id, 0).await?; assert_eq!(msgs.len(), 3); // enable protection on promoted chat, the info-message is sent via send_msg() this time chat_id .set_protection(&t, ProtectionStatus::Protected) - .await - .unwrap(); - let chat = Chat::load_from_db(&t, chat_id).await.unwrap(); + .await?; + let chat = Chat::load_from_db(&t, chat_id).await?; assert!(chat.is_protected()); assert!(!chat.is_unpromoted()); @@ -4619,6 +4615,8 @@ mod tests { assert!(msg.is_info()); assert_eq!(msg.get_info_type(), SystemMessage::ChatProtectionEnabled); assert_eq!(msg.get_state(), MessageState::OutDelivered); // as bcc-self is disabled and there is nobody else in the chat + + Ok(()) } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] diff --git a/src/config.rs b/src/config.rs index d3fe61d25..3574a5aef 100644 --- a/src/config.rs +++ b/src/config.rs @@ -55,7 +55,7 @@ pub enum Config { Selfstatus, Selfavatar, - #[strum(props(default = "0"))] + #[strum(props(default = "1"))] BccSelf, #[strum(props(default = "1"))] diff --git a/src/webxdc.rs b/src/webxdc.rs index 3d21d0f4d..087fc607d 100644 --- a/src/webxdc.rs +++ b/src/webxdc.rs @@ -948,6 +948,7 @@ mod tests { async fn test_resend_webxdc_instance_and_info() -> Result<()> { // Alice uses webxdc in a group let alice = TestContext::new_alice().await; + alice.set_config_bool(Config::BccSelf, false).await?; let alice_grp = create_group_chat(&alice, ProtectionStatus::Unprotected, "grp").await?; let alice_instance = send_webxdc_instance(&alice, alice_grp).await?; assert_eq!(alice_grp.get_msg_cnt(&alice).await?, 1);