mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
re-add quotes in SEARCH command, comment
This commit is contained in:
@@ -335,7 +335,8 @@ impl Context {
|
|||||||
|
|
||||||
// Separate impl block for self address handling
|
// Separate impl block for self address handling
|
||||||
impl Context {
|
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> {
|
pub(crate) async fn is_self_addr(&self, addr: &str) -> Result<bool> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.get_config(Config::ConfiguredAddr)
|
.get_config(Config::ConfiguredAddr)
|
||||||
|
|||||||
10
src/imap.rs
10
src/imap.rs
@@ -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)
|
/// 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> {
|
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
|
// 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? {
|
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)
|
Ok(search_command)
|
||||||
@@ -2555,19 +2555,19 @@ mod tests {
|
|||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_imap_self_sent_search_command(&t.ctx).await?,
|
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?;
|
t.ctx.set_primary_self_addr("alice@another.com").await?;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_imap_self_sent_search_command(&t.ctx).await?,
|
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?;
|
t.ctx.set_primary_self_addr("alice@third.com").await?;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
get_imap_self_sent_search_command(&t.ctx).await?,
|
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(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user