aboutsummaryrefslogtreecommitdiff
path: root/src/imap/command/anonymous.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-01-01 19:25:28 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-01-01 19:25:28 +0100
commit07eea38765aecbd53e51be199094eba2871dc7ad (patch)
tree590b136365f43d1602442620161aee8b256bc998 /src/imap/command/anonymous.rs
parente2d77defc8496c2795860c6901d752e2c8d1c4ac (diff)
downloadaerogramme-07eea38765aecbd53e51be199094eba2871dc7ad.tar.gz
aerogramme-07eea38765aecbd53e51be199094eba2871dc7ad.zip
ported commands
Diffstat (limited to 'src/imap/command/anonymous.rs')
-rw-r--r--src/imap/command/anonymous.rs40
1 files changed, 13 insertions, 27 deletions
diff --git a/src/imap/command/anonymous.rs b/src/imap/command/anonymous.rs
index 9bbb3b7..42e2a87 100644
--- a/src/imap/command/anonymous.rs
+++ b/src/imap/command/anonymous.rs
@@ -4,6 +4,7 @@ use imap_codec::imap_types::core::{AString, NonEmptyVec};
use imap_codec::imap_types::response::{Capability, Data};
use imap_codec::imap_types::secret::Secret;
+use crate::imap::command::anystate;
use crate::imap::flow;
use crate::imap::response::Response;
use crate::login::ArcLoginProvider;
@@ -18,26 +19,20 @@ pub struct AnonymousContext<'a> {
pub async fn dispatch(ctx: AnonymousContext<'_>) -> Result<(Response, flow::Transition)> {
match &ctx.req.body {
- CommandBody::Noop => Ok((
- Response::ok()
- .to_req(ctx.req)
- .message("Noop completed.")
- .build()?,
- flow::Transition::None,
- )),
- CommandBody::Capability => ctx.capability().await,
- CommandBody::Logout => ctx.logout().await,
+ // Any State
+ CommandBody::Noop => anystate::noop_nothing(ctx.req.tag.clone()),
+ CommandBody::Capability => anystate::capability(ctx.req.tag.clone()),
+ CommandBody::Logout => Ok((Response::bye()?, flow::Transition::Logout)),
+
+ // Specific to anonymous context (3 commands)
CommandBody::Login { username, password } => ctx.login(username, password).await,
- cmd => {
- tracing::warn!("Unknown command for the anonymous state {:?}", cmd);
- Ok((
- Response::bad()
- .to_req(ctx.req)
- .message("Command unavailable")
- .build()?,
- flow::Transition::None,
- ))
+ CommandBody::Authenticate { .. } => {
+ anystate::not_implemented(ctx.req.tag.clone(), "authenticate")
}
+ //StartTLS is not implemented for now, we will probably go full TLS.
+
+ // Collect other commands
+ _ => anystate::wrong_state(ctx.req.tag.clone()),
}
}
@@ -91,13 +86,4 @@ impl<'a> AnonymousContext<'a> {
flow::Transition::Authenticate(user),
))
}
-
- // C: 10 logout
- // S: * BYE Logging out
- // S: 10 OK Logout completed.
- async fn logout(self) -> Result<(Response, flow::Transition)> {
- // @FIXME we should implement From<Vec<Status>> and From<Vec<ImapStatus>> in
- // boitalettres/src/proto/res/body.rs
- Ok((Response::bye()?, flow::Transition::Logout))
- }
}