diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-01-06 23:24:44 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-01-06 23:24:44 +0100 |
commit | 4e3cbf79d03c84028733b0ad5f9bd06a8a13757b (patch) | |
tree | 010c193730931adc1a925ebe6689b39ce4d73012 | |
parent | 5622a71cd163e4b18a3eabe8a28a5aedb23ee25d (diff) | |
download | aerogramme-4e3cbf79d03c84028733b0ad5f9bd06a8a13757b.tar.gz aerogramme-4e3cbf79d03c84028733b0ad5f9bd06a8a13757b.zip |
implemented text search
-rw-r--r-- | src/imap/mail_view.rs | 6 | ||||
-rw-r--r-- | src/imap/search.rs | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/imap/mail_view.rs b/src/imap/mail_view.rs index 365e535..baeb2af 100644 --- a/src/imap/mail_view.rs +++ b/src/imap/mail_view.rs @@ -261,7 +261,7 @@ impl<'a> FetchedMail<'a> { Self::Partial(AnyPart::Msg(msg)) } - fn as_anypart(&self) -> Result<&AnyPart<'a>> { + pub fn as_anypart(&self) -> Result<&AnyPart<'a>> { match self { FetchedMail::Full(x) => Ok(&x), FetchedMail::Partial(x) => Ok(&x), @@ -269,7 +269,7 @@ impl<'a> FetchedMail<'a> { } } - fn as_msg(&self) -> Result<&Message<'a>> { + pub fn as_msg(&self) -> Result<&Message<'a>> { match self { FetchedMail::Full(AnyPart::Msg(x)) => Ok(&x), FetchedMail::Partial(AnyPart::Msg(x)) => Ok(&x), @@ -277,7 +277,7 @@ impl<'a> FetchedMail<'a> { } } - fn as_imf(&self) -> Option<&imf::Imf<'a>> { + pub fn as_imf(&self) -> Option<&imf::Imf<'a>> { match self { FetchedMail::Full(AnyPart::Msg(x)) => Some(&x.imf), FetchedMail::Partial(AnyPart::Msg(x)) => Some(&x.imf), diff --git a/src/imap/search.rs b/src/imap/search.rs index 2fbfdcc..fb889d7 100644 --- a/src/imap/search.rs +++ b/src/imap/search.rs @@ -190,7 +190,7 @@ impl<'a> Criteria<'a> { And(expr_list) => expr_list .as_ref() .iter() - .any(|cur| Criteria(cur).is_keep_on_query(mail_view)), + .all(|cur| Criteria(cur).is_keep_on_query(mail_view)), Or(left, right) => { Criteria(left).is_keep_on_query(mail_view) || Criteria(right).is_keep_on_query(mail_view) } @@ -234,8 +234,8 @@ impl<'a> Criteria<'a> { // Filter on the full content of the email - Text(_) => unimplemented!(), - Body(_) => unimplemented!(), + Text(txt) => mail_view.content.as_msg().map(|msg| msg.raw_part.windows(txt.as_ref().len()).any(|win| win == txt.as_ref())).unwrap_or(false), + Body(txt) => mail_view.content.as_msg().map(|msg| msg.raw_body.windows(txt.as_ref().len()).any(|win| win == txt.as_ref())).unwrap_or(false), unknown => { tracing::error!("Unknown filter {:?}", unknown); |