feat: do not log the recipient list for sent messages

This commit is contained in:
link2xt
2026-06-15 13:41:40 +00:00
committed by l
parent c7a399e3ca
commit 3e10cf2c07
2 changed files with 16 additions and 28 deletions
+3 -12
View File
@@ -37,19 +37,14 @@ def test_one_account_send_bcc_setting(acfactory, log, direct_imap):
log.section("send out message without bcc to ourselves") log.section("send out message without bcc to ourselves")
ac1.set_config("bcc_self", "0") ac1.set_config("bcc_self", "0")
chat = ac1.create_chat(ac2) chat = ac1.create_chat(ac2)
self_addr = ac1.get_config("addr")
other_addr = ac2.get_config("addr")
msg_out = chat.send_text("message1") msg_out = chat.send_text("message1")
assert not msg_out.get_snapshot().is_forwarded assert not msg_out.get_snapshot().is_forwarded
# wait for send out (no BCC) # wait for send out (no BCC)
ev = ac1.wait_for_event(EventType.SMTP_MESSAGE_SENT) ac1.wait_for_event(EventType.SMTP_MESSAGE_SENT)
assert ac1.get_config("bcc_self") == "0" assert ac1.get_config("bcc_self") == "0"
assert self_addr not in ev.msg
assert other_addr in ev.msg
log.section("ac1: setting bcc_self=1") log.section("ac1: setting bcc_self=1")
ac1.set_config("bcc_self", "1") ac1.set_config("bcc_self", "1")
@@ -57,20 +52,16 @@ def test_one_account_send_bcc_setting(acfactory, log, direct_imap):
msg_out = chat.send_text("message2") msg_out = chat.send_text("message2")
# wait for send out (BCC) # wait for send out (BCC)
ev = ac1.wait_for_event(EventType.SMTP_MESSAGE_SENT) ac1.wait_for_event(EventType.SMTP_MESSAGE_SENT)
assert ac1.get_config("bcc_self") == "1" assert ac1.get_config("bcc_self") == "1"
# Second client receives only second message, but not the first. # Second client receives only the second message, but not the first.
ev_msg = ac1_clone.wait_for_event(EventType.MSGS_CHANGED) ev_msg = ac1_clone.wait_for_event(EventType.MSGS_CHANGED)
assert ac1_clone.get_message_by_id(ev_msg.msg_id).get_snapshot().text == "Messages are end-to-end encrypted." assert ac1_clone.get_message_by_id(ev_msg.msg_id).get_snapshot().text == "Messages are end-to-end encrypted."
ev_msg = ac1_clone.wait_for_event(EventType.MSGS_CHANGED) ev_msg = ac1_clone.wait_for_event(EventType.MSGS_CHANGED)
assert ac1_clone.get_message_by_id(ev_msg.msg_id).get_snapshot().text == msg_out.get_snapshot().text assert ac1_clone.get_message_by_id(ev_msg.msg_id).get_snapshot().text == msg_out.get_snapshot().text
# now make sure we are sending message to ourselves too
assert self_addr in ev.msg
assert self_addr in ev.msg
# BCC-self messages are marked as seen by the sender device. # BCC-self messages are marked as seen by the sender device.
while True: while True:
event = ac1.wait_for_event() event = ac1.wait_for_event()
+13 -16
View File
@@ -40,31 +40,28 @@ impl Smtp {
} }
let message_len_bytes = message.len(); let message_len_bytes = message.len();
let recipients_display = recipients
.iter()
.map(|x| x.as_ref())
.collect::<Vec<&str>>()
.join(",");
let envelope = let envelope =
Envelope::new(self.from.clone(), recipients.to_vec()).map_err(Error::Envelope)?; Envelope::new(self.from.clone(), recipients.to_vec()).map_err(Error::Envelope)?;
let mail = SendableEmail::new(envelope, message); let mail = SendableEmail::new(envelope, message);
if let Some(ref mut transport) = self.transport { let Some(ref mut transport) = self.transport else {
transport.send(mail).await.map_err(Error::SmtpSend)?;
let info_msg =
format!("Message len={message_len_bytes} was SMTP-sent to {recipients_display}");
info!(context, "{info_msg}.");
context.emit_event(EventType::SmtpMessageSent(info_msg));
self.last_success = Some(tools::Time::now());
} else {
warn!( warn!(
context, context,
"uh? SMTP has no transport, failed to send to {}", recipients_display "Failed to send a message because SMTP client has no SmtpTransport."
); );
return Err(Error::NoTransport); return Err(Error::NoTransport);
} };
transport.send(mail).await.map_err(Error::SmtpSend)?;
let info_msg = format!(
"Message len={message_len_bytes} was SMTP-sent to {} recipients.",
recipients.len()
);
info!(context, "{info_msg}.");
context.emit_event(EventType::SmtpMessageSent(info_msg));
self.last_success = Some(tools::Time::now());
Ok(()) Ok(())
} }
} }