re-add quotes in SEARCH command, comment

This commit is contained in:
Hocuri
2022-04-24 12:41:45 +02:00
committed by holger krekel
parent 9e1770316a
commit c10dc7b25b
2 changed files with 7 additions and 6 deletions

View File

@@ -335,7 +335,8 @@ impl Context {
// Separate impl block for self address handling
impl Context {
/// determine whether the specified addr maps to the/a self addr
/// Determine whether the specified addr maps to the/a self addr.
/// Returns `false` if no addresses are configured.
pub(crate) async fn is_self_addr(&self, addr: &str) -> Result<bool> {
Ok(self
.get_config(Config::ConfiguredAddr)

View File

@@ -2172,10 +2172,10 @@ async fn get_modseq(context: &Context, folder: &str) -> Result<u64> {
/// Compute the imap search expression for all self-sent mails (for all self addresses)
pub(crate) async fn get_imap_self_sent_search_command(context: &Context) -> Result<String> {
// See https://www.rfc-editor.org/rfc/rfc3501#section-6.4.4 for syntax of SEARCH and OR
let mut search_command = format!("FROM {}", context.get_primary_self_addr().await?);
let mut search_command = format!("FROM \"{}\"", context.get_primary_self_addr().await?);
for item in context.get_secondary_self_addrs().await? {
search_command = format!("OR ({}) (FROM {})", search_command, item);
search_command = format!("OR ({}) (FROM \"{}\")", search_command, item);
}
Ok(search_command)
@@ -2555,19 +2555,19 @@ mod tests {
let t = TestContext::new_alice().await;
assert_eq!(
get_imap_self_sent_search_command(&t.ctx).await?,
"FROM alice@example.org"
r#"FROM "alice@example.org""#
);
t.ctx.set_primary_self_addr("alice@another.com").await?;
assert_eq!(
get_imap_self_sent_search_command(&t.ctx).await?,
"OR (FROM alice@another.com) (FROM alice@example.org)"
r#"OR (FROM "alice@another.com") (FROM "alice@example.org")"#
);
t.ctx.set_primary_self_addr("alice@third.com").await?;
assert_eq!(
get_imap_self_sent_search_command(&t.ctx).await?,
"OR (OR (FROM alice@third.com) (FROM alice@another.com)) (FROM alice@example.org)"
r#"OR (OR (FROM "alice@third.com") (FROM "alice@another.com")) (FROM "alice@example.org")"#
);
Ok(())