diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 4c15d2936..0666149cd 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -6912,12 +6912,12 @@ void dc_event_unref(dc_event_t* event); /// "Autocrypt Setup Message" /// -/// Used in subjects of outgoing Autocrypt Setup Messages. +/// @deprecated 2025-04 #define DC_STR_AC_SETUP_MSG_SUBJECT 42 /// "This is the Autocrypt Setup Message, open it in a compatible client to use your setup" /// -/// Used as message text of outgoing Autocrypt Setup Messages. +/// @deprecated 2025-04 #define DC_STR_AC_SETUP_MSG_BODY 43 /// "Cannot login as %1$s." diff --git a/src/constants.rs b/src/constants.rs index 8facfbb8e..d4a1e326f 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -220,6 +220,19 @@ pub(crate) const SECUREJOIN_WAIT_TIMEOUT: u64 = 15; // Newer Delta Chats will remove the prefix as needed. pub(crate) const EDITED_PREFIX: &str = "✏️"; +// Strings needed to render the Autocrypt Setup Message. +// Left untranslated as not being supported/recommended workflow and as translations would require deep knowledge. +pub(crate) const ASM_SUBJECT: &str = "Autocrypt Setup Message"; +pub(crate) const ASM_BODY: &str = "This is the Autocrypt Setup Message \ + used to transfer your end-to-end setup between clients. + + To decrypt and use your setup, \ + open the message in an Autocrypt-compliant client \ + and enter the setup code presented on the generating device. + + If you see this message in a chatmail client (Delta Chat, Arcane Chat, Delta Touch ...), \ + use \"Settings / Add Second Device\" instead."; + #[cfg(test)] mod tests { use num_traits::FromPrimitive; diff --git a/src/imex/key_transfer.rs b/src/imex/key_transfer.rs index 57c2b3094..75f369c0d 100644 --- a/src/imex/key_transfer.rs +++ b/src/imex/key_transfer.rs @@ -6,6 +6,7 @@ use anyhow::{bail, ensure, Result}; use crate::blob::BlobObject; use crate::chat::{self, ChatId}; use crate::config::Config; +use crate::constants::{ASM_BODY, ASM_SUBJECT}; use crate::contact::ContactId; use crate::context::Context; use crate::imex::set_self_key; @@ -14,7 +15,6 @@ use crate::message::{Message, MsgId, Viewtype}; use crate::mimeparser::SystemMessage; use crate::param::Param; use crate::pgp; -use crate::stock_str; use crate::tools::open_file_std; /// Initiates key transfer via Autocrypt Setup Message. @@ -39,7 +39,7 @@ pub async fn initiate_key_transfer(context: &Context) -> Result { msg.param.set(Param::File, setup_file_blob.as_name()); msg.param .set(Param::Filename, "autocrypt-setup-message.html"); - msg.subject = stock_str::ac_setup_msg_subject(context).await; + msg.subject = ASM_SUBJECT.to_owned(); msg.param .set(Param::MimeType, "application/autocrypt-setup"); msg.param.set_cmd(SystemMessage::AutocryptSetupMessage); @@ -113,8 +113,8 @@ pub async fn render_setup_file(context: &Context, passphrase: &str) -> Result"); Ok(format!( concat!( @@ -187,7 +187,6 @@ mod tests { use crate::pgp::{split_armored_data, HEADER_AUTOCRYPT, HEADER_SETUPCODE}; use crate::receive_imf::receive_imf; - use crate::stock_str::StockMessage; use crate::test_utils::{TestContext, TestContextManager}; use ::pgp::armor::BlockType; @@ -213,12 +212,9 @@ mod tests { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_render_setup_file_newline_replace() { let t = TestContext::new_alice().await; - t.set_stock_translation(StockMessage::AcSetupMsgBody, "hello\r\nthere".to_string()) - .await - .unwrap(); let msg = render_setup_file(&t, "pw").await.unwrap(); println!("{}", &msg); - assert!(msg.contains("

hello
there

")); + assert!(msg.contains("

This is the Autocrypt Setup Message used to transfer your end-to-end setup between clients.
")); } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] diff --git a/src/mimefactory.rs b/src/mimefactory.rs index 8632401a8..55c6684d4 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -16,6 +16,7 @@ use tokio::fs; use crate::blob::BlobObject; use crate::chat::{self, Chat}; use crate::config::Config; +use crate::constants::ASM_SUBJECT; use crate::constants::{Chattype, DC_FROM_HANDSHAKE}; use crate::contact::{Contact, ContactId, Origin}; use crate::context::Context; @@ -1303,7 +1304,7 @@ impl MimeFactory { mail_builder::headers::raw::Raw::new("v1").into(), )); - placeholdertext = Some(stock_str::ac_setup_msg_body(context).await); + placeholdertext = Some(ASM_SUBJECT.to_string()); } SystemMessage::SecurejoinMessage => { let step = msg.param.get(Param::Arg).unwrap_or_default(); diff --git a/src/stock_str.rs b/src/stock_str.rs index 6508fecc8..e8e727b83 100644 --- a/src/stock_str.rs +++ b/src/stock_str.rs @@ -95,14 +95,6 @@ pub enum StockMessage { #[strum(props(fallback = "Archived chats"))] ArchivedChats = 40, - #[strum(props(fallback = "Autocrypt Setup Message"))] - AcSetupMsgSubject = 42, - - #[strum(props( - fallback = "This is the Autocrypt Setup Message used to transfer your key between clients.\n\nTo decrypt and use your key, open the message in an Autocrypt-compliant client and enter the setup code presented on the generating device." - ))] - AcSetupMsgBody = 43, - #[strum(props( fallback = "Cannot login as \"%1$s\". Please check if the email address and the password are correct." ))] @@ -889,16 +881,6 @@ pub(crate) async fn archived_chats(context: &Context) -> String { translated(context, StockMessage::ArchivedChats).await } -/// Stock string: `Autocrypt Setup Message`. -pub(crate) async fn ac_setup_msg_subject(context: &Context) -> String { - translated(context, StockMessage::AcSetupMsgSubject).await -} - -/// Stock string: `This is the Autocrypt Setup Message used to transfer...`. -pub(crate) async fn ac_setup_msg_body(context: &Context) -> String { - translated(context, StockMessage::AcSetupMsgBody).await -} - /// Stock string: `Multi Device Synchronization`. pub(crate) async fn sync_msg_subject(context: &Context) -> String { translated(context, StockMessage::SyncMsgSubject).await diff --git a/src/summary.rs b/src/summary.rs index 2f38c5d00..027348e16 100644 --- a/src/summary.rs +++ b/src/summary.rs @@ -204,17 +204,10 @@ impl Message { append_text = true } Viewtype::File => { - if self.param.get_cmd() == SystemMessage::AutocryptSetupMessage { - emoji = None; - type_name = Some(stock_str::ac_setup_msg_subject(context).await); - type_file = None; - append_text = false; - } else { - emoji = Some("📎"); - type_name = Some(stock_str::file(context).await); - type_file = self.get_filename(); - append_text = true - } + emoji = Some("📎"); + type_name = Some(stock_str::file(context).await); + type_file = self.get_filename(); + append_text = true } Viewtype::VideochatInvitation => { emoji = None; @@ -469,10 +462,10 @@ mod tests { ); // skipping prefix used for reactions summaries let mut msg = Message::new(Viewtype::File); - msg.set_text(some_text.clone()); - msg.set_file_from_bytes(ctx, "foo.bar", b"data", None) + msg.set_file_from_bytes(ctx, "autocrypt-setup-message.html", b"data", None) .unwrap(); msg.param.set_cmd(SystemMessage::AutocryptSetupMessage); - assert_summary_texts(&msg, ctx, "Autocrypt Setup Message").await; // file name is not added for autocrypt setup messages + assert_summary_texts(&msg, ctx, "📎 autocrypt-setup-message.html").await; + // no special handling of ASM } }