diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-06-28 15:38:06 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-06-28 15:38:06 +0200 |
commit | 06b888d9696cf7270c6daff4d5ae8a0591e265fe (patch) | |
tree | b56daa5d76290a1d00ccf16c4a1b6caf0fe99c8f /src/imap/command/anonymous.rs | |
parent | 36bbc2138bceb0c80a306f8c225e340d6fbd5470 (diff) | |
download | aerogramme-06b888d9696cf7270c6daff4d5ae8a0591e265fe.tar.gz aerogramme-06b888d9696cf7270c6daff4d5ae8a0591e265fe.zip |
Implement logout
Diffstat (limited to 'src/imap/command/anonymous.rs')
-rw-r--r-- | src/imap/command/anonymous.rs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/imap/command/anonymous.rs b/src/imap/command/anonymous.rs index 8de27cb..2ab3f97 100644 --- a/src/imap/command/anonymous.rs +++ b/src/imap/command/anonymous.rs @@ -1,8 +1,8 @@ use anyhow::{Error, Result}; -use boitalettres::proto::Response; +use boitalettres::proto::{res::body::Data as Body, Response}; use imap_codec::types::command::CommandBody; -use imap_codec::types::core::AString; -use imap_codec::types::response::{Capability, Data, Response as ImapRes, Status}; +use imap_codec::types::core::{AString, Atom}; +use imap_codec::types::response::{Capability, Code, Data, Response as ImapRes, Status}; use crate::imap::flow; use crate::imap::session::InnerContext; @@ -13,6 +13,7 @@ pub async fn dispatch<'a>(ctx: InnerContext<'a>) -> Result<(Response, flow::Tran match &ctx.req.command.body { CommandBody::Noop => Ok((Response::ok("Noop completed.")?, flow::Transition::No)), CommandBody::Capability => capability(ctx).await, + CommandBody::Logout => logout(ctx).await, CommandBody::Login { username, password } => login(ctx, username, password).await, _ => Ok(( Response::no("This command is not available in the ANONYMOUS state.")?, @@ -59,3 +60,17 @@ async fn login<'a>( flow::Transition::Authenticate(user), )) } +// C: 10 logout +// S: * BYE Logging out +// S: 10 OK Logout completed. +async fn logout<'a>(ctx: InnerContext<'a>) -> Result<(Response, flow::Transition)> { + // @FIXME we should implement From<Vec<Status>> and From<Vec<ImapStatus>> in + // boitalettres/src/proto/res/body.rs + Ok(( + Response::ok("Logout completed")?.with_body(vec![Body::Status( + Status::bye(None, "Logging out") + .map_err(|e| Error::msg(e).context("Unable to generate IMAP status"))?, + )]), + flow::Transition::Logout, + )) +} |