Skip to content

Commit 531e0bc

Browse files
authored
refactor!: Remove some unneeded stock strings (#7496)
There are quite some unneeded stock strings; this PR removes some of them. None of these stock strings were actually set by the UI, or even have translations in Transifex. - We don't have AEAP anymore. - The "I added/removed member" and "I left the group" strings are anyways not meant to be shown to the user. Also, starting to translate them now would leak the device language. BREAKING CHANGE: This can theoretically be a breaking change because a UI could reference one of the removed stock strings, so I marked it as breaking just in case.
1 parent 3637fe6 commit 531e0bc

File tree

7 files changed

+7
-138
lines changed

7 files changed

+7
-138
lines changed

deltachat-ffi/deltachat.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7416,19 +7416,6 @@ void dc_event_unref(dc_event_t* event);
74167416
/// @deprecated 2025-06-05
74177417
#define DC_STR_AEAP_ADDR_CHANGED 122
74187418

7419-
/// "You changed your email address from %1$s to %2$s.
7420-
/// If you now send a message to a group, contacts there will automatically
7421-
/// replace the old with your new address.\n\n It's highly advised to set up
7422-
/// your old email provider to forward all emails to your new email address.
7423-
/// Otherwise you might miss messages of contacts who did not get your new
7424-
/// address yet." + the link to the AEAP blog post
7425-
///
7426-
/// As soon as there is a post about AEAP, the UIs should add it:
7427-
/// set_stock_translation(123, getString(aeap_explanation) + "\n\n" + AEAP_BLOG_LINK)
7428-
///
7429-
/// Used in a device message that explains AEAP.
7430-
#define DC_STR_AEAP_EXPLANATION_AND_LINK 123
7431-
74327419
/// "You changed group name from \"%1$s\" to \"%2$s\"."
74337420
///
74347421
/// `%1$s` will be replaced by the old group name.
@@ -7677,12 +7664,6 @@ void dc_event_unref(dc_event_t* event);
76777664
/// Used in info messages.
76787665
#define DC_STR_CHAT_PROTECTION_ENABLED 170
76797666

7680-
/// "%1$s sent a message from another device."
7681-
///
7682-
/// Used in info messages.
7683-
/// @deprecated 2025-07
7684-
#define DC_STR_CHAT_PROTECTION_DISABLED 171
7685-
76867667
/// "Others will only see this group after you sent a first message."
76877668
///
76887669
/// Used as the first info messages in newly created groups.

src/chat/chat_tests.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3312,10 +3312,7 @@ async fn test_leave_broadcast_multidevice() -> Result<()> {
33123312

33133313
let leave_msg = bob0.pop_sent_msg().await;
33143314
let parsed = MimeMessage::from_bytes(bob1, leave_msg.payload().as_bytes(), None).await?;
3315-
assert_eq!(
3316-
parsed.parts[0].msg,
3317-
stock_str::msg_group_left_remote(bob0).await
3318-
);
3315+
assert_eq!(parsed.parts[0].msg, "I left the group.");
33193316

33203317
let rcvd = bob1.recv_msg(&leave_msg).await;
33213318

src/configure.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::config::{self, Config};
2727
use crate::constants::NON_ALPHANUMERIC_WITHOUT_DOT;
2828
use crate::context::Context;
2929
use crate::imap::Imap;
30-
use crate::log::{LogExt, warn};
30+
use crate::log::warn;
3131
use crate::login_param::EnteredCertificateChecks;
3232
pub use crate::login_param::EnteredLoginParam;
3333
use crate::message::Message;
@@ -44,7 +44,6 @@ use crate::transport::{
4444
};
4545
use crate::{EventType, stock_str};
4646
use crate::{chat, provider};
47-
use deltachat_contact_tools::addr_cmp;
4847

4948
macro_rules! progress {
5049
($context:tt, $progress:expr, $comment:expr) => {
@@ -267,15 +266,14 @@ impl Context {
267266
let provider = configure(self, param).await?;
268267
self.set_config_internal(Config::NotifyAboutWrongPw, Some("1"))
269268
.await?;
270-
on_configure_completed(self, provider, old_addr).await?;
269+
on_configure_completed(self, provider).await?;
271270
Ok(())
272271
}
273272
}
274273

275274
async fn on_configure_completed(
276275
context: &Context,
277276
provider: Option<&'static Provider>,
278-
old_addr: Option<String>,
279277
) -> Result<()> {
280278
if let Some(provider) = provider {
281279
if let Some(config_defaults) = provider.config_defaults {
@@ -305,20 +303,6 @@ async fn on_configure_completed(
305303
}
306304
}
307305

308-
if let Some(new_addr) = context.get_config(Config::ConfiguredAddr).await?
309-
&& let Some(old_addr) = old_addr
310-
&& !addr_cmp(&new_addr, &old_addr)
311-
{
312-
let mut msg = Message::new_text(
313-
stock_str::aeap_explanation_and_link(context, &old_addr, &new_addr).await,
314-
);
315-
chat::add_device_msg(context, None, Some(&mut msg))
316-
.await
317-
.context("Cannot add AEAP explanation")
318-
.log_err(context)
319-
.ok();
320-
}
321-
322306
Ok(())
323307
}
324308

src/contact.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,18 +1509,6 @@ impl Contact {
15091509
&self.addr
15101510
}
15111511

1512-
/// Get authorized name or address.
1513-
///
1514-
/// This string is suitable for sending over email
1515-
/// as it does not leak the locally set name.
1516-
pub(crate) fn get_authname_or_addr(&self) -> String {
1517-
if !self.authname.is_empty() {
1518-
(&self.authname).into()
1519-
} else {
1520-
(&self.addr).into()
1521-
}
1522-
}
1523-
15241512
/// Get a summary of name and address.
15251513
///
15261514
/// The returned string is either "Name ([email protected])" or just

src/mimefactory.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,10 +1521,9 @@ impl MimeFactory {
15211521
.await?
15221522
.unwrap_or_default()
15231523
{
1524-
placeholdertext = Some(stock_str::msg_group_left_remote(context).await);
1524+
placeholdertext = Some("I left the group.".to_string());
15251525
} else {
1526-
placeholdertext =
1527-
Some(stock_str::msg_del_member_remote(context, email_to_remove).await);
1526+
placeholdertext = Some(format!("I removed member {email_to_remove}."));
15281527
};
15291528

15301529
if !email_to_remove.is_empty() {
@@ -1547,8 +1546,7 @@ impl MimeFactory {
15471546
let email_to_add = msg.param.get(Param::Arg).unwrap_or_default();
15481547
let fingerprint_to_add = msg.param.get(Param::Arg4).unwrap_or_default();
15491548

1550-
placeholdertext =
1551-
Some(stock_str::msg_add_member_remote(context, email_to_add).await);
1549+
placeholdertext = Some(format!("I added member {email_to_add}."));
15521550

15531551
if !email_to_add.is_empty() {
15541552
headers.push((

src/stock_str.rs

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::accounts::Accounts;
1313
use crate::blob::BlobObject;
1414
use crate::chat::{self, Chat, ChatId};
1515
use crate::config::Config;
16-
use crate::contact::{Contact, ContactId, Origin};
16+
use crate::contact::{Contact, ContactId};
1717
use crate::context::Context;
1818
use crate::message::{Message, Viewtype};
1919
use crate::param::Param;
@@ -241,11 +241,6 @@ pub enum StockMessage {
241241
#[strum(props(fallback = "Not connected"))]
242242
NotConnected = 121,
243243

244-
#[strum(props(
245-
fallback = "You changed your email address from %1$s to %2$s.\n\nIf you now send a message to a verified group, contacts there will automatically replace the old with your new address.\n\nIt's highly advised to set up your old email provider to forward all emails to your new email address. Otherwise you might miss messages of contacts who did not get your new address yet."
246-
))]
247-
AeapExplanationAndLink = 123,
248-
249244
#[strum(props(fallback = "You changed group name from \"%1$s\" to \"%2$s\"."))]
250245
MsgYouChangedGrpName = 124,
251246

@@ -356,22 +351,9 @@ pub enum StockMessage {
356351
#[strum(props(fallback = "ℹ️ Account transferred to your second device."))]
357352
BackupTransferMsgBody = 163,
358353

359-
#[strum(props(fallback = "I added member %1$s."))]
360-
MsgIAddMember = 164,
361-
362-
#[strum(props(fallback = "I removed member %1$s."))]
363-
MsgIDelMember = 165,
364-
365-
#[strum(props(fallback = "I left the group."))]
366-
MsgILeftGroup = 166,
367-
368354
#[strum(props(fallback = "Messages are end-to-end encrypted."))]
369355
ChatProtectionEnabled = 170,
370356

371-
// deprecated 2025-07
372-
#[strum(props(fallback = "%1$s sent a message from another device."))]
373-
ChatProtectionDisabled = 171,
374-
375357
#[strum(props(fallback = "Others will only see this group after you sent a first message."))]
376358
NewGroupSendFirstMessage = 172,
377359

@@ -626,25 +608,6 @@ pub(crate) async fn msg_grp_img_changed(context: &Context, by_contact: ContactId
626608
}
627609
}
628610

629-
/// Stock string: `I added member %1$s.`.
630-
/// This one is for sending in group chats.
631-
///
632-
/// The `added_member_addr` parameter should be an email address and is looked up in the
633-
/// contacts to combine with the authorized display name.
634-
pub(crate) async fn msg_add_member_remote(context: &Context, added_member_addr: &str) -> String {
635-
let addr = added_member_addr;
636-
let whom = &match Contact::lookup_id_by_addr(context, addr, Origin::Unknown).await {
637-
Ok(Some(contact_id)) => Contact::get_by_id(context, contact_id)
638-
.await
639-
.map(|contact| contact.get_authname_or_addr())
640-
.unwrap_or_else(|_| addr.to_string()),
641-
_ => addr.to_string(),
642-
};
643-
translated(context, StockMessage::MsgIAddMember)
644-
.await
645-
.replace1(whom)
646-
}
647-
648611
/// Stock string: `You added member %1$s.` or `Member %1$s added by %2$s.`.
649612
///
650613
/// The `added_member_addr` parameter should be an email address and is looked up in the
@@ -671,24 +634,6 @@ pub(crate) async fn msg_add_member_local(
671634
}
672635
}
673636

674-
/// Stock string: `I removed member %1$s.`.
675-
///
676-
/// The `removed_member_addr` parameter should be an email address and is looked up in
677-
/// the contacts to combine with the display name.
678-
pub(crate) async fn msg_del_member_remote(context: &Context, removed_member_addr: &str) -> String {
679-
let addr = removed_member_addr;
680-
let whom = &match Contact::lookup_id_by_addr(context, addr, Origin::Unknown).await {
681-
Ok(Some(contact_id)) => Contact::get_by_id(context, contact_id)
682-
.await
683-
.map(|contact| contact.get_authname_or_addr())
684-
.unwrap_or_else(|_| addr.to_string()),
685-
_ => addr.to_string(),
686-
};
687-
translated(context, StockMessage::MsgIDelMember)
688-
.await
689-
.replace1(whom)
690-
}
691-
692637
/// Stock string: `I added member %1$s.` or `Member %1$s removed by %2$s.`.
693638
///
694639
/// The `removed_member_addr` parameter should be an email address and is looked up in
@@ -715,11 +660,6 @@ pub(crate) async fn msg_del_member_local(
715660
}
716661
}
717662

718-
/// Stock string: `I left the group.`.
719-
pub(crate) async fn msg_group_left_remote(context: &Context) -> String {
720-
translated(context, StockMessage::MsgILeftGroup).await
721-
}
722-
723663
/// Stock string: `You left the group.` or `Group left by %1$s.`.
724664
pub(crate) async fn msg_group_left_local(context: &Context, by_contact: ContactId) -> String {
725665
if by_contact == ContactId::SELF {
@@ -1293,17 +1233,6 @@ pub(crate) async fn stats_msg_body(context: &Context) -> String {
12931233
translated(context, StockMessage::StatsMsgBody).await
12941234
}
12951235

1296-
pub(crate) async fn aeap_explanation_and_link(
1297-
context: &Context,
1298-
old_addr: &str,
1299-
new_addr: &str,
1300-
) -> String {
1301-
translated(context, StockMessage::AeapExplanationAndLink)
1302-
.await
1303-
.replace1(old_addr)
1304-
.replace2(new_addr)
1305-
}
1306-
13071236
/// Stock string: `Others will only see this group after you sent a first message.`.
13081237
pub(crate) async fn new_group_send_first_message(context: &Context) -> String {
13091238
translated(context, StockMessage::NewGroupSendFirstMessage).await

src/stock_str/stock_str_tests.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ async fn test_stock_system_msg_add_member_by_me() {
7575
let alice_contact_id = Contact::create(&t, "Alice", "[email protected]")
7676
.await
7777
.expect("failed to create contact");
78-
assert_eq!(
79-
msg_add_member_remote(&t, "[email protected]").await,
80-
"I added member [email protected]."
81-
);
8278
assert_eq!(
8379
msg_add_member_local(&t, alice_contact_id, ContactId::SELF).await,
8480
"You added member Alice."
@@ -91,10 +87,6 @@ async fn test_stock_system_msg_add_member_by_me_with_displayname() {
9187
let alice_contact_id = Contact::create(&t, "Alice", "[email protected]")
9288
.await
9389
.expect("failed to create contact");
94-
assert_eq!(
95-
msg_add_member_remote(&t, "[email protected]").await,
96-
"I added member [email protected]."
97-
);
9890
assert_eq!(
9991
msg_add_member_local(&t, alice_contact_id, ContactId::SELF).await,
10092
"You added member Alice."

0 commit comments

Comments
 (0)