Do not include email address in identity names (closes #1688)

This commit is contained in:
mdecimus 2025-06-24 09:58:51 +02:00
parent d6fa4fa8dc
commit 854bfcb249
3 changed files with 20 additions and 6 deletions

View file

@ -167,7 +167,6 @@ impl IdentityGet for Server {
// Create identities
let name = principal.description.unwrap_or(principal.name);
let has_many = num_emails > 1;
let mut next_document_id = self
.store()
.assign_document_ids(account_id, Collection::Identity, num_emails as u64)
@ -175,13 +174,11 @@ impl IdentityGet for Server {
.caused_by(trc::location!())?;
for email in &principal.emails {
let email = sanitize_email(email).unwrap_or_default();
if email.is_empty() {
if email.is_empty() || email.starts_with('@') {
continue;
}
let name = if name.is_empty() {
email.clone()
} else if has_many {
format!("{} <{}>", name, email)
} else {
name.clone()
};

View file

@ -34,10 +34,14 @@ pub async fn test(mut imap: &mut ImapConnection, mut imap_check: &mut ImapConnec
imap.assert_read(Type::Tagged, ResponseType::Ok).await;
imap.send("CREATE \"Fruit/Apple/Green\"").await;
imap.assert_read(Type::Tagged, ResponseType::Ok).await;
imap.send("CREATE \"L&APg-bende opgaver\"").await;
imap.assert_read(Type::Tagged, ResponseType::Ok).await;
// Select folder from another connection
other_conn.send("SELECT \"Tofu\"").await;
other_conn.assert_read(Type::Tagged, ResponseType::Ok).await;
other_conn.send("SELECT \"L&APg-bende opgaver\"").await;
other_conn.assert_read(Type::Tagged, ResponseType::Ok).await;
// Make sure folders are visible
for imap in [&mut imap, &mut imap_check] {
@ -52,10 +56,13 @@ pub async fn test(mut imap: &mut ImapConnection, mut imap_check: &mut ImapConnec
("Fruit/Apple", [""]),
("Fruit/Apple/Green", [""]),
("Tofu", [""]),
("L&APg-bende opgaver", [""]),
],
true,
);
}
imap.send("DELETE \"L&APg-bende opgaver\"").await;
imap.assert_read(Type::Tagged, ResponseType::Ok).await;
// Special use folders that already exist should not be allowed
imap.send("CREATE \"Second trash\" (USE (\\Trash))").await;
@ -65,6 +72,16 @@ pub async fn test(mut imap: &mut ImapConnection, mut imap_check: &mut ImapConnec
imap.send("ENABLE IMAP4rev2").await;
imap.assert_read(Type::Tagged, ResponseType::Ok).await;
// Create and delete using IMAP4rev2
imap.send("CREATE \"L&APg-bende opgaver\"").await;
imap.assert_read(Type::Tagged, ResponseType::Ok).await;
imap.send("SELECT \"L&APg-bende opgaver\"").await;
imap.assert_read(Type::Tagged, ResponseType::Ok).await;
imap.send("UNSELECT \"L&APg-bende opgaver\"").await;
imap.assert_read(Type::Tagged, ResponseType::Ok).await;
imap.send("DELETE \"L&APg-bende opgaver\"").await;
imap.assert_read(Type::Tagged, ResponseType::Ok).await;
// Create missing parent folders
imap.send("CREATE \"/Vegetable/Broccoli\" (USE (\\Important))")
.await;

View file

@ -76,7 +76,7 @@ pub async fn webdav_tests() {
//test_build_itip_templates(&handle.server).await;
/* basic::test(&handle).await;
basic::test(&handle).await;
put_get::test(&handle).await;
mkcol::test(&handle).await;
copy_move::test(&handle).await;
@ -89,7 +89,7 @@ pub async fn webdav_tests() {
card_query::test(&handle).await;
cal_query::test(&handle).await;
cal_alarm::test(&handle).await;
cal_itip::test();*/
cal_itip::test();
cal_scheduling::test(&handle).await;
// Print elapsed time