From 18ace81842d64cbce24bfee4926769a2c10733b4 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sun, 20 Jun 2021 00:00:00 +0000 Subject: [PATCH] Create chats for outgoing classic mails Previously chats created by outgoing classic emails went into contact requests (deaddrop). Outgoing messages are not shown in contact requests, so created chat was not shown anywhere. With this fix chat is created both for outgoing classic emails and outgoing chat emails. --- src/dc_receive_imf.rs | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 84fc99265..f18e11d46 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -730,9 +730,7 @@ async fn add_parts( } } if chat_id.is_unset() && allow_creation { - let create_blocked = if MessengerMessage::No != is_dc_message - && !Contact::is_blocked_load(context, to_id).await - { + let create_blocked = if !Contact::is_blocked_load(context, to_id).await { Blocked::Not } else { Blocked::Deaddrop @@ -4035,4 +4033,37 @@ Message content", let msg = t.get_last_msg().await; assert_ne!(msg.chat_id, t.get_self_chat().await.id); } + + #[async_std::test] + async fn test_outgoing_classic_mail_creates_chat() { + let alice = TestContext::new_alice().await; + + // Alice enables classic emails. + alice + .set_config(Config::ShowEmails, Some("2")) + .await + .unwrap(); + + // Alice downloads outgoing classic email. + dc_receive_imf( + &alice, + b"Received: from [127.0.0.1] +Subject: Subj +Message-ID: +To: +From: + +Message content", + "Sent", + 1, + false, + ) + .await + .unwrap(); + + // Outgoing email should create a chat. + let msg = alice.get_last_msg().await; + assert_ne!(msg.chat_id, DC_CHAT_ID_DEADDROP); + assert_eq!(msg.get_text().unwrap(), "Subj – Message content"); + } }