diff options
author | Quentin <quentin@dufour.io> | 2024-01-08 10:39:26 +0000 |
---|---|---|
committer | Quentin <quentin@dufour.io> | 2024-01-08 10:39:26 +0000 |
commit | d7788e29a8a64550e9b274001ff3fb9a7bf3473b (patch) | |
tree | e43a11753472f1917ce4aa6ddba24ae3a513bd50 /src/mail | |
parent | 152d5b7604337fe19a7aea7fc37b3d4615ca7393 (diff) | |
parent | 42a54b2c500294c594f3efdd25db28c18f5ac238 (diff) | |
download | aerogramme-d7788e29a8a64550e9b274001ff3fb9a7bf3473b.tar.gz aerogramme-d7788e29a8a64550e9b274001ff3fb9a7bf3473b.zip |
Merge pull request 'Implement search' (#61) from feat/search into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/aerogramme/pulls/61
Diffstat (limited to 'src/mail')
-rw-r--r-- | src/mail/mailbox.rs | 4 | ||||
-rw-r--r-- | src/mail/mod.rs | 4 | ||||
-rw-r--r-- | src/mail/query.rs | 9 | ||||
-rw-r--r-- | src/mail/snapshot.rs | 2 | ||||
-rw-r--r-- | src/mail/user.rs | 5 |
5 files changed, 18 insertions, 6 deletions
diff --git a/src/mail/mailbox.rs b/src/mail/mailbox.rs index 2a0a24a..7eed34f 100644 --- a/src/mail/mailbox.rs +++ b/src/mail/mailbox.rs @@ -39,7 +39,11 @@ impl Mailbox { .await?; } + // @FIXME reporting through opentelemetry or some logs + // info on the "shape" of the mailbox would be welcomed + /* dump(&uid_index); + */ let mbox = RwLock::new(MailboxInternal { id, diff --git a/src/mail/mod.rs b/src/mail/mod.rs index 1836052..37578b8 100644 --- a/src/mail/mod.rs +++ b/src/mail/mod.rs @@ -1,5 +1,4 @@ use std::convert::TryFrom; -use std::io::Write; pub mod incoming; pub mod mailbox; @@ -22,9 +21,6 @@ impl<'a> TryFrom<&'a [u8]> for IMF<'a> { type Error = (); fn try_from(body: &'a [u8]) -> Result<IMF<'a>, ()> { - eprintln!("---- BEGIN PARSED MESSAGE ----"); - let _ = std::io::stderr().write_all(body); - eprintln!("---- END PARSED MESSAGE ----"); let parsed = eml_codec::parse_message(body).or(Err(()))?.1; Ok(Self { raw: body, parsed }) } diff --git a/src/mail/query.rs b/src/mail/query.rs index 8de73e6..91bd6c1 100644 --- a/src/mail/query.rs +++ b/src/mail/query.rs @@ -19,6 +19,15 @@ pub enum QueryScope { Partial, Full, } +impl QueryScope { + pub fn union(&self, other: &QueryScope) -> QueryScope { + match (self, other) { + (QueryScope::Full, _) | (_, QueryScope::Full) => QueryScope::Full, + (QueryScope::Partial, _) | (_, QueryScope::Partial) => QueryScope::Partial, + (QueryScope::Index, QueryScope::Index) => QueryScope::Index, + } + } +} impl<'a, 'b> Query<'a, 'b> { pub async fn fetch(&self) -> Result<Vec<QueryResult<'a>>> { diff --git a/src/mail/snapshot.rs b/src/mail/snapshot.rs index 0834f09..ed756b5 100644 --- a/src/mail/snapshot.rs +++ b/src/mail/snapshot.rs @@ -11,8 +11,6 @@ use super::unique_ident::UniqueIdent; /// state that is desynchronized with the real mailbox state. /// It's up to the user to choose when their snapshot must be updated /// to give useful information to their clients -/// -/// pub struct FrozenMailbox { pub mailbox: Arc<Mailbox>, pub snapshot: UidIndex, diff --git a/src/mail/user.rs b/src/mail/user.rs index da0d509..5af86d0 100644 --- a/src/mail/user.rs +++ b/src/mail/user.rs @@ -71,10 +71,15 @@ impl User { /// Opens an existing mailbox given its IMAP name. pub async fn open_mailbox(&self, name: &str) -> Result<Option<Arc<Mailbox>>> { let (mut list, ct) = self.load_mailbox_list().await?; + + //@FIXME it could be a trace or an opentelemtry trace thing. + // Be careful to not leak sensible data + /* eprintln!("List of mailboxes:"); for ent in list.0.iter() { eprintln!(" - {:?}", ent); } + */ if let Some((uidvalidity, Some(mbid))) = list.get_mailbox(name) { let mb = self.open_mailbox_by_id(mbid, uidvalidity).await?; |