aboutsummaryrefslogtreecommitdiff
path: root/src/imap/command/authenticated.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-01-03 20:53:07 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-01-03 20:53:07 +0100
commita6a0e1994db2b43f559e5c2e8ae5c58342e5136f (patch)
tree3a48395a42f3128af21d32cf23c94dc0898e6287 /src/imap/command/authenticated.rs
parent7de1c66d86dbfe8e8ef4ed1183e5a9b6a3a636bf (diff)
downloadaerogramme-a6a0e1994db2b43f559e5c2e8ae5c58342e5136f.tar.gz
aerogramme-a6a0e1994db2b43f559e5c2e8ae5c58342e5136f.zip
ENABLE is now supported
Diffstat (limited to 'src/imap/command/authenticated.rs')
-rw-r--r--src/imap/command/authenticated.rs25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/imap/command/authenticated.rs b/src/imap/command/authenticated.rs
index fbf29f9..ee7c8f3 100644
--- a/src/imap/command/authenticated.rs
+++ b/src/imap/command/authenticated.rs
@@ -3,14 +3,15 @@ use std::sync::Arc;
use anyhow::{anyhow, bail, Result};
use imap_codec::imap_types::command::{Command, CommandBody};
-use imap_codec::imap_types::core::{Atom, Literal, QuotedChar};
+use imap_codec::imap_types::core::{Atom, Literal, QuotedChar, NonEmptyVec};
use imap_codec::imap_types::datetime::DateTime;
use imap_codec::imap_types::flag::{Flag, FlagNameAttribute};
use imap_codec::imap_types::mailbox::{ListMailbox, Mailbox as MailboxCodec};
use imap_codec::imap_types::response::{Code, CodeOther, Data};
use imap_codec::imap_types::status::{StatusDataItem, StatusDataItemName};
+use imap_codec::imap_types::extensions::enable::CapabilityEnable;
-use crate::imap::capability::ServerCapability;
+use crate::imap::capability::{ClientCapability, ServerCapability};
use crate::imap::command::{anystate, MailboxName};
use crate::imap::flow;
use crate::imap::mailbox_view::MailboxView;
@@ -24,6 +25,7 @@ use crate::mail::IMF;
pub struct AuthenticatedContext<'a> {
pub req: &'a Command<'static>,
pub server_capabilities: &'a ServerCapability,
+ pub client_capabilities: &'a mut ClientCapability,
pub user: &'a Arc<User>,
}
@@ -65,6 +67,11 @@ pub async fn dispatch<'a>(
message,
} => ctx.append(mailbox, flags, date, message).await,
+ // rfc5161 ENABLE
+ CommandBody::Enable { capabilities } => {
+ ctx.enable(capabilities)
+ },
+
// Collect other commands
_ => anystate::wrong_state(ctx.req.tag.clone()),
}
@@ -511,6 +518,20 @@ impl<'a> AuthenticatedContext<'a> {
}
}
+ fn enable(self, cap_enable: &NonEmptyVec<CapabilityEnable<'static>>) -> Result<(Response<'static>, flow::Transition)> {
+ let mut response_builder = Response::build().to_req(self.req);
+ let capabilities = self.client_capabilities.try_enable(cap_enable.as_ref());
+ if capabilities.len() > 0 {
+ response_builder = response_builder.data(Data::Enabled { capabilities });
+ }
+ Ok((
+ response_builder
+ .message("ENABLE completed")
+ .ok()?,
+ flow::Transition::None,
+ ))
+ }
+
pub(crate) async fn append_internal(
self,
mailbox: &MailboxCodec<'a>,