feat: Don't SMTP-send messages to self-chat if BccSelf is disabled

`chat::create_send_msg_jobs()` already handles `Config::BccSelf` as needed. The only exception is
Autocrypt setup messages. This change unifies the logic for the self-chat and groups only containing
`SELF`.
This commit is contained in:
iequidoo
2024-09-14 23:11:29 -03:00
committed by iequidoo
parent b69488685f
commit 5b597f3a95
3 changed files with 17 additions and 2 deletions

View File

@@ -620,7 +620,7 @@ def test_long_group_name(acfactory, lp):
def test_send_self_message(acfactory, lp): def test_send_self_message(acfactory, lp):
ac1 = acfactory.new_online_configuring_account(mvbox_move=True) ac1 = acfactory.new_online_configuring_account(mvbox_move=True, bcc_self=True)
acfactory.bring_accounts_online() acfactory.bring_accounts_online()
lp.sec("ac1: create self chat") lp.sec("ac1: create self chat")
chat = ac1.get_self_contact().create_chat() chat = ac1.get_self_contact().create_chat()

View File

@@ -143,7 +143,9 @@ impl MimeFactory {
let mut req_mdn = false; let mut req_mdn = false;
if chat.is_self_talk() { if chat.is_self_talk() {
recipients.push((from_displayname.to_string(), from_addr.to_string())); if msg.param.get_cmd() == SystemMessage::AutocryptSetupMessage {
recipients.push((from_displayname.to_string(), from_addr.to_string()));
}
} else if chat.is_mailing_list() { } else if chat.is_mailing_list() {
let list_post = chat let list_post = chat
.param .param

View File

@@ -2107,6 +2107,19 @@ async fn test_no_unencrypted_name_in_self_chat() -> Result<()> {
Ok(()) Ok(())
} }
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_no_smtp_job_for_self_chat() -> Result<()> {
let mut tcm = TestContextManager::new();
let bob = &tcm.bob().await;
bob.set_config_bool(Config::BccSelf, false).await?;
let chat_id = bob.get_self_chat().await.id;
let mut msg = Message::new(Viewtype::Text);
msg.text = "Happy birthday to me".to_string();
chat::send_msg(bob, chat_id, &mut msg).await?;
assert!(bob.pop_sent_msg_opt(Duration::ZERO).await.is_none());
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_outgoing_classic_mail_creates_chat() { async fn test_outgoing_classic_mail_creates_chat() {
let alice = TestContext::new_alice().await; let alice = TestContext::new_alice().await;