Skip to content

Commit 5d334ee

Browse files
committed
fix: Don't SMTP-send self-only messages if DeleteServerAfter is "immediate" (#6661)
1 parent dc17f26 commit 5d334ee

File tree

5 files changed

+20
-9
lines changed

5 files changed

+20
-9
lines changed

deltachat-rpc-client/tests/test_key_transfer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def test_autocrypt_setup_message_key_transfer(acfactory):
2121
alice2.set_config("addr", alice1.get_config("addr"))
2222
alice2.set_config("mail_pw", alice1.get_config("mail_pw"))
2323
alice2.configure()
24+
alice2.bring_online()
2425

2526
setup_code = alice1.initiate_autocrypt_key_transfer()
2627
msg = wait_for_autocrypt_setup_message(alice2)
@@ -34,10 +35,12 @@ def test_autocrypt_setup_message_key_transfer(acfactory):
3435

3536
def test_ac_setup_message_twice(acfactory):
3637
alice1 = acfactory.get_online_account()
38+
3739
alice2 = acfactory.get_unconfigured_account()
3840
alice2.set_config("addr", alice1.get_config("addr"))
3941
alice2.set_config("mail_pw", alice1.get_config("mail_pw"))
4042
alice2.configure()
43+
alice2.bring_online()
4144

4245
# Send the first Autocrypt Setup Message and ignore it.
4346
_setup_code = alice1.initiate_autocrypt_key_transfer()

src/chat.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,10 +3029,10 @@ pub(crate) async fn create_send_msg_jobs(context: &Context, msg: &mut Message) -
30293029
// disabled by default is fine.
30303030
//
30313031
// `from` must be the last addr, see `receive_imf_inner()` why.
3032-
if context.get_config_bool(Config::BccSelf).await?
3033-
&& !recipients
3034-
.iter()
3035-
.any(|x| x.to_lowercase() == lowercase_from)
3032+
recipients.retain(|x| x.to_lowercase() != lowercase_from);
3033+
if (context.get_config_bool(Config::BccSelf).await?
3034+
|| msg.param.get_cmd() == SystemMessage::AutocryptSetupMessage)
3035+
&& (context.get_config_delete_server_after().await? != Some(0) || !recipients.is_empty())
30363036
{
30373037
recipients.push(from);
30383038
}

src/imex/key_transfer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ pub async fn initiate_key_transfer(context: &Context) -> Result<String> {
4646
msg.force_plaintext();
4747
msg.param.set_int(Param::SkipAutocrypt, 1);
4848

49-
chat::send_msg(context, chat_id, &mut msg).await?;
50-
5149
// Enable BCC-self, because transferring a key
5250
// means we have a multi-device setup.
5351
context.set_config_bool(Config::BccSelf, true).await?;
52+
53+
chat::send_msg(context, chat_id, &mut msg).await?;
5454
Ok(setup_code)
5555
}
5656

src/mimefactory.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,6 @@ impl MimeFactory {
184184
let mut req_mdn = false;
185185

186186
if chat.is_self_talk() {
187-
if msg.param.get_cmd() == SystemMessage::AutocryptSetupMessage {
188-
recipients.push(from_addr.to_string());
189-
}
190187
to.push((from_displayname.to_string(), from_addr.to_string()));
191188
} else if chat.is_mailing_list() {
192189
let list_post = chat

src/receive_imf/receive_imf_tests.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,6 +2218,17 @@ async fn test_no_smtp_job_for_self_chat() -> Result<()> {
22182218
let mut msg = Message::new_text("Happy birthday to me".to_string());
22192219
chat::send_msg(bob, chat_id, &mut msg).await?;
22202220
assert!(bob.pop_sent_msg_opt(Duration::ZERO).await.is_none());
2221+
2222+
bob.set_config_bool(Config::BccSelf, true).await?;
2223+
bob.set_config(Config::DeleteServerAfter, Some("1")).await?;
2224+
let mut msg = Message::new_text("Happy birthday to me".to_string());
2225+
chat::send_msg(bob, chat_id, &mut msg).await?;
2226+
assert!(bob.pop_sent_msg_opt(Duration::ZERO).await.is_none());
2227+
2228+
bob.set_config(Config::DeleteServerAfter, None).await?;
2229+
let mut msg = Message::new_text("Happy birthday to me".to_string());
2230+
chat::send_msg(bob, chat_id, &mut msg).await?;
2231+
assert!(bob.pop_sent_msg_opt(Duration::ZERO).await.is_some());
22212232
Ok(())
22222233
}
22232234

0 commit comments

Comments
 (0)