aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-01-02 22:32:02 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-01-02 22:32:02 +0100
commit0cc13f891cdcdc474416cdb63d48245a1820af10 (patch)
tree3274652bc50eaae4cab9ffd8c3d031ee6432a17f
parentb66b9f75fe0c078dfd34dd45d5ce80786aba8c2c (diff)
downloadaerogramme-0cc13f891cdcdc474416cdb63d48245a1820af10.tar.gz
aerogramme-0cc13f891cdcdc474416cdb63d48245a1820af10.zip
migration to imap-flow seems done!refactor/imap-flow
-rw-r--r--src/imap/command/authenticated.rs1
-rw-r--r--src/imap/command/examined.rs12
-rw-r--r--src/imap/command/selected.rs12
3 files changed, 19 insertions, 6 deletions
diff --git a/src/imap/command/authenticated.rs b/src/imap/command/authenticated.rs
index 74ebbfa..1bb4c6d 100644
--- a/src/imap/command/authenticated.rs
+++ b/src/imap/command/authenticated.rs
@@ -432,6 +432,7 @@ impl<'a> AuthenticatedContext<'a> {
Ok((
Response::build()
.message("Select completed")
+ .to_req(self.req)
.code(Code::ReadWrite)
.set_body(data)
.ok()?,
diff --git a/src/imap/command/examined.rs b/src/imap/command/examined.rs
index eec85cd..7de94f4 100644
--- a/src/imap/command/examined.rs
+++ b/src/imap/command/examined.rs
@@ -7,7 +7,7 @@ use imap_codec::imap_types::fetch::MacroOrMessageDataItemNames;
use imap_codec::imap_types::search::SearchKey;
use imap_codec::imap_types::sequence::SequenceSet;
-use crate::imap::command::anystate;
+use crate::imap::command::{anystate, authenticated};
use crate::imap::flow;
use crate::imap::mailbox_view::MailboxView;
use crate::imap::response::Response;
@@ -48,8 +48,14 @@ pub async fn dispatch(ctx: ExaminedContext<'_>) -> Result<(Response<'static>, fl
flow::Transition::None,
)),
- // The command does not belong to this state
- _ => anystate::wrong_state(ctx.req.tag.clone()),
+ // In examined mode, we fallback to authenticated when needed
+ _ => {
+ authenticated::dispatch(authenticated::AuthenticatedContext {
+ req: ctx.req,
+ user: ctx.user,
+ })
+ .await
+ }
}
}
diff --git a/src/imap/command/selected.rs b/src/imap/command/selected.rs
index d5dcd61..220a952 100644
--- a/src/imap/command/selected.rs
+++ b/src/imap/command/selected.rs
@@ -10,7 +10,7 @@ use imap_codec::imap_types::response::{Code, CodeOther};
use imap_codec::imap_types::search::SearchKey;
use imap_codec::imap_types::sequence::SequenceSet;
-use crate::imap::command::{anystate, MailboxName};
+use crate::imap::command::{anystate, authenticated, MailboxName};
use crate::imap::flow;
use crate::imap::mailbox_view::MailboxView;
use crate::imap::response::Response;
@@ -59,8 +59,14 @@ pub async fn dispatch<'a>(
uid,
} => ctx.copy(sequence_set, mailbox, uid).await,
- // The command does not belong to this state
- _ => anystate::wrong_state(ctx.req.tag.clone()),
+ // In selected mode, we fallback to authenticated when needed
+ _ => {
+ authenticated::dispatch(authenticated::AuthenticatedContext {
+ req: ctx.req,
+ user: ctx.user,
+ })
+ .await
+ }
}
}