diff --git a/ui/src/cache.rs b/ui/src/cache.rs index 13d9bc0e..b6332797 100644 --- a/ui/src/cache.rs +++ b/ui/src/cache.rs @@ -52,6 +52,7 @@ pub enum Query { AllText(String), /* * * * */ Flags(Vec), + HasAttachment, And(Box, Box), Or(Box, Box), Not(Box), @@ -127,6 +128,14 @@ pub mod query_parser { } } + fn has_attachment<'a>() -> impl Parser<'a, Query> { + move |input| { + whitespace_wrap(match_literal_anycase("has:attachment")) + .map(|()| Query::HasAttachment) + .parse(input) + } + } + fn literal<'a>() -> impl Parser<'a, String> { move |input| either(quoted_string(), string()).parse(input) } @@ -196,6 +205,7 @@ pub mod query_parser { .or(bcc().parse(input)) .or(subject().parse(input)) .or(flags().parse(input)) + .or(has_attachment().parse(input)) { Ok(q) } else if let Ok((rest, query_a)) = not().parse(input) { diff --git a/ui/src/sqlite3.rs b/ui/src/sqlite3.rs index 7a5b6796..70c5f747 100644 --- a/ui/src/sqlite3.rs +++ b/ui/src/sqlite3.rs @@ -461,6 +461,9 @@ pub fn query_to_sql(q: &Query) -> String { s.push_str(") "); } } + HasAttachment => { + s.push_str("has_attachments == 1 "); + } _ => {} } }