ui/sqlite3: add has:attachment query

jmap
Manos Pitsidianakis 2019-11-11 22:59:37 +02:00
parent 35e34d1c09
commit c9c4e1ea60
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
2 changed files with 13 additions and 0 deletions

View File

@ -52,6 +52,7 @@ pub enum Query {
AllText(String),
/* * * * */
Flags(Vec<String>),
HasAttachment,
And(Box<Query>, Box<Query>),
Or(Box<Query>, Box<Query>),
Not(Box<Query>),
@ -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) {

View File

@ -461,6 +461,9 @@ pub fn query_to_sql(q: &Query) -> String {
s.push_str(") ");
}
}
HasAttachment => {
s.push_str("has_attachments == 1 ");
}
_ => {}
}
}