Replace "End-to-end-encryption unavailable unexpectedly" with translatable string

This commit is contained in:
link2xt
2026-05-15 22:08:27 +02:00
parent 0643cf0cb1
commit 4747fa70ff
2 changed files with 29 additions and 4 deletions

View File

@@ -2895,11 +2895,26 @@ pub(crate) async fn create_send_msg_jobs(context: &Context, msg: &mut Message) -
}
if needs_encryption && !rendered_msg.is_encrypted {
/* unrecoverable */
message::set_msg_failed(
let addr = context.get_config(Config::ConfiguredAddr).await?;
let text = stock_str::unencrypted_email(
context,
msg,
"End-to-end-encryption unavailable unexpectedly.",
addr.unwrap_or_default()
.split('@')
.nth(1)
.unwrap_or_default(),
)
.await;
message::set_msg_failed(context, msg, &text).await?;
add_info_msg_with_cmd(
context,
msg.chat_id,
&text,
SystemMessage::InvalidUnencryptedMail,
Some(msg.timestamp_sort),
msg.timestamp_sort,
None,
None,
None,
)
.await?;
bail!(

View File

@@ -113,6 +113,7 @@ mod tests {
use crate::chat::send_text_msg;
use crate::config::Config;
use crate::message::Message;
use crate::mimeparser::SystemMessage;
use crate::receive_imf::receive_imf;
use crate::test_utils::{TestContext, TestContextManager};
@@ -165,6 +166,15 @@ Sent with my Delta Chat Messenger: https://delta.chat";
let mut msg = Message::new_text("Hello!".to_string());
assert!(chat::send_msg(alice, chat.id, &mut msg).await.is_err());
assert_eq!(
msg.error().unwrap(),
"\u{26a0}\u{fe0f} Your email provider example.org requires end-to-end encryption which is not setup yet."
);
let info_msg = alice.get_last_msg().await;
assert_eq!(
info_msg.get_info_type(),
SystemMessage::InvalidUnencryptedMail
);
Ok(())
}