aboutsummaryrefslogtreecommitdiff
path: root/src/imap/command/anonymous.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-01-02 20:23:33 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-01-02 20:23:33 +0100
commit0d667a30301bec47c03314ff0e449a220ad3b913 (patch)
treeb3f5ccbbe5e5a615fc278900328bbcaccc9d8c6f /src/imap/command/anonymous.rs
parent9a8d4c651e5993f09f54cf7c1eacf7a4839ea9db (diff)
downloadaerogramme-0d667a30301bec47c03314ff0e449a220ad3b913.tar.gz
aerogramme-0d667a30301bec47c03314ff0e449a220ad3b913.zip
compile with imap-flow
Diffstat (limited to 'src/imap/command/anonymous.rs')
-rw-r--r--src/imap/command/anonymous.rs22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/imap/command/anonymous.rs b/src/imap/command/anonymous.rs
index 4de5fbd..fbd10e9 100644
--- a/src/imap/command/anonymous.rs
+++ b/src/imap/command/anonymous.rs
@@ -1,7 +1,6 @@
use anyhow::Result;
use imap_codec::imap_types::command::{Command, CommandBody};
-use imap_codec::imap_types::core::{AString, NonEmptyVec};
-use imap_codec::imap_types::response::{Capability, Data};
+use imap_codec::imap_types::core::AString;
use imap_codec::imap_types::secret::Secret;
use crate::imap::command::anystate;
@@ -13,16 +12,16 @@ use crate::mail::user::User;
//--- dispatching
pub struct AnonymousContext<'a> {
- pub req: &'a Command<'a>,
+ pub req: &'a Command<'static>,
pub login_provider: &'a ArcLoginProvider,
}
-pub async fn dispatch<'a>(ctx: AnonymousContext<'a>) -> Result<(Response<'a>, flow::Transition)> {
+pub async fn dispatch(ctx: AnonymousContext<'_>) -> Result<(Response<'static>, flow::Transition)> {
match &ctx.req.body {
// 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)),
+ CommandBody::Logout => anystate::logout(),
// Specific to anonymous context (3 commands)
CommandBody::Login { username, password } => ctx.login(username, password).await,
@@ -39,22 +38,11 @@ pub async fn dispatch<'a>(ctx: AnonymousContext<'a>) -> Result<(Response<'a>, fl
//--- Command controllers, private
impl<'a> AnonymousContext<'a> {
- async fn capability(self) -> Result<(Response<'a>, flow::Transition)> {
- let capabilities: NonEmptyVec<Capability> =
- (vec![Capability::Imap4Rev1, Capability::Idle]).try_into()?;
- let res = Response::build()
- .to_req(self.req)
- .message("Server capabilities")
- .data(Data::Capability(capabilities))
- .ok()?;
- Ok((res, flow::Transition::None))
- }
-
async fn login(
self,
username: &AString<'a>,
password: &Secret<AString<'a>>,
- ) -> Result<(Response<'a>, flow::Transition)> {
+ ) -> Result<(Response<'static>, flow::Transition)> {
let (u, p) = (
std::str::from_utf8(username.as_ref())?,
std::str::from_utf8(password.declassify().as_ref())?,