From 0c6e745d11725b4a15d2c380f5bb60067c26ddd9 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 10 Jan 2024 14:45:36 +0100 Subject: update imap-codec --- Cargo.lock | 8 +++++--- Cargo.toml | 10 ++++------ src/imap/index.rs | 14 +++++--------- src/imap/mod.rs | 5 +++++ 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f8d3bf9..fed2cd5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1806,7 +1806,8 @@ dependencies = [ [[package]] name = "imap-codec" -version = "1.0.0" +version = "2.0.0" +source = "git+https://github.com/superboum/imap-codec?branch=custom/aerogramme#4c7891d400e69c864fc079463bbd2c28e2d46cf3" dependencies = [ "abnf-core", "base64 0.21.5", @@ -1821,7 +1822,7 @@ dependencies = [ [[package]] name = "imap-flow" version = "0.1.0" -source = "git+https://github.com/duesee/imap-flow.git?rev=e45ce7bb6ab6bda3c71a0c7b05e9b558a5902e90#e45ce7bb6ab6bda3c71a0c7b05e9b558a5902e90" +source = "git+https://github.com/superboum/imap-flow.git?branch=custom/aerogramme#525429781f375580cba824de584593b242245ff7" dependencies = [ "bounded-static", "bytes", @@ -1832,7 +1833,8 @@ dependencies = [ [[package]] name = "imap-types" -version = "1.0.0" +version = "2.0.0" +source = "git+https://github.com/superboum/imap-codec?branch=custom/aerogramme#4c7891d400e69c864fc079463bbd2c28e2d46cf3" dependencies = [ "base64 0.21.5", "bounded-static", diff --git a/Cargo.toml b/Cargo.toml index 1e8cc16..55f0284 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,16 +58,14 @@ aws-sdk-s3 = "1.9.0" eml-codec = { git = "https://git.deuxfleurs.fr/Deuxfleurs/eml-codec.git", branch = "main" } smtp-message = { git = "http://github.com/Alexis211/kannader", branch = "feature/lmtp" } smtp-server = { git = "http://github.com/Alexis211/kannader", branch = "feature/lmtp" } -imap-codec = { version = "1.0.0", features = ["bounded-static", "ext_condstore_qresync"] } -imap-flow = { git = "https://github.com/duesee/imap-flow.git", rev = "e45ce7bb6ab6bda3c71a0c7b05e9b558a5902e90" } +imap-codec = { version = "2.0.0", features = ["bounded-static", "ext_condstore_qresync"] } +imap-flow = { git = "https://github.com/superboum/imap-flow.git", branch = "custom/aerogramme" } [dev-dependencies] [patch.crates-io] -#imap-types = { git = "https://github.com/duesee/imap-codec", branch = "v2" } -#imap-codec = { git = "https://github.com/duesee/imap-codec", branch = "v2" } -imap-types = { path = "../../imap-codec/imap-types" } -imap-codec = { path = "../../imap-codec/imap-codec" } +imap-types = { git = "https://github.com/superboum/imap-codec", branch = "custom/aerogramme" } +imap-codec = { git = "https://github.com/superboum/imap-codec", branch = "custom/aerogramme" } [[test]] name = "behavior" diff --git a/src/imap/index.rs b/src/imap/index.rs index 95c16b3..da94022 100644 --- a/src/imap/index.rs +++ b/src/imap/index.rs @@ -1,7 +1,7 @@ use std::num::NonZeroU32; use anyhow::{anyhow, Result}; -use imap_codec::imap_types::sequence::{self, SeqOrUid, Sequence, SequenceSet}; +use imap_codec::imap_types::sequence::{SeqOrUid, Sequence, SequenceSet}; use crate::mail::uidindex::{ImapUid, UidIndex}; use crate::mail::unique_ident::UniqueIdent; @@ -61,10 +61,8 @@ impl<'a> Index<'a> { if self.imap_index.is_empty() { return vec![]; } - let iter_strat = sequence::Strategy::Naive { - largest: self.last().expect("The mailbox is not empty").uid, - }; - let mut unroll_seq = sequence_set.iter(iter_strat).collect::>(); + let largest = self.last().expect("The mailbox is not empty").uid; + let mut unroll_seq = sequence_set.iter(largest).collect::>(); unroll_seq.sort(); let start_seq = match unroll_seq.iter().next() { @@ -103,11 +101,9 @@ impl<'a> Index<'a> { if self.imap_index.is_empty() { return Ok(vec![]); } - let iter_strat = sequence::Strategy::Naive { - largest: NonZeroU32::try_from(self.imap_index.len() as u32)?, - }; + let largest = NonZeroU32::try_from(self.imap_index.len() as u32)?; let mut acc = sequence_set - .iter(iter_strat) + .iter(largest) .map(|wanted_id| { self.imap_index .get((wanted_id.get() as usize) - 1) diff --git a/src/imap/mod.rs b/src/imap/mod.rs index 2640183..61a265a 100644 --- a/src/imap/mod.rs +++ b/src/imap/mod.rs @@ -175,6 +175,11 @@ async fn client(mut ctx: ClientContext) -> Result<()> { } } }, + flow => { + server.enqueue_status(Status::bye(None, "Unsupported server flow event").unwrap()); + tracing::error!("session task exited for {:?} due to unsupported flow {:?}", ctx.addr, flow); + + } }, // Managing response generated by Aerogramme -- cgit v1.2.3