aboutsummaryrefslogtreecommitdiff
path: root/src/imap/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/imap/mod.rs')
-rw-r--r--src/imap/mod.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/imap/mod.rs b/src/imap/mod.rs
index 31eeaa8..693c99a 100644
--- a/src/imap/mod.rs
+++ b/src/imap/mod.rs
@@ -3,6 +3,7 @@ mod flow;
mod mailbox_view;
mod response;
mod session;
+mod capability;
use std::net::SocketAddr;
@@ -17,12 +18,14 @@ use imap_flow::server::{ServerFlow, ServerFlowEvent, ServerFlowOptions};
use imap_flow::stream::AnyStream;
use crate::config::ImapConfig;
+use crate::imap::capability::ServerCapability;
use crate::login::ArcLoginProvider;
/// Server is a thin wrapper to register our Services in BàL
pub struct Server {
bind_addr: SocketAddr,
login_provider: ArcLoginProvider,
+ capabilities: ServerCapability,
}
struct ClientContext {
@@ -30,12 +33,14 @@ struct ClientContext {
addr: SocketAddr,
login_provider: ArcLoginProvider,
must_exit: watch::Receiver<bool>,
+ server_capabilities: ServerCapability,
}
pub fn new(config: ImapConfig, login: ArcLoginProvider) -> Server {
Server {
bind_addr: config.bind_addr,
login_provider: login,
+ capabilities: ServerCapability::default(),
}
}
@@ -66,6 +71,7 @@ impl Server {
addr: remote_addr.clone(),
login_provider: self.login_provider.clone(),
must_exit: must_exit.clone(),
+ server_capabilities: self.capabilities.clone(),
};
let conn = tokio::spawn(client_wrapper(client));
connections.push(conn);
@@ -96,21 +102,21 @@ async fn client(mut ctx: ClientContext) -> Result<()> {
let (mut server, _) = ServerFlow::send_greeting(
ctx.stream,
ServerFlowOptions::default(),
- Greeting::ok(None, "Aerogramme").unwrap(),
+ Greeting::ok(Some(Code::Capability(ctx.server_capabilities.to_vec())), "Aerogramme").unwrap(),
)
.await?;
use crate::imap::response::{Body, Response as MyResponse};
use crate::imap::session::Instance;
use imap_codec::imap_types::command::Command;
- use imap_codec::imap_types::response::{Response, Status};
+ use imap_codec::imap_types::response::{Response, Code, Status};
use tokio::sync::mpsc;
let (cmd_tx, mut cmd_rx) = mpsc::channel::<Command<'static>>(10);
let (resp_tx, mut resp_rx) = mpsc::unbounded_channel::<MyResponse<'static>>();
let bckgrnd = tokio::spawn(async move {
- let mut session = Instance::new(ctx.login_provider);
+ let mut session = Instance::new(ctx.login_provider, ctx.server_capabilities);
loop {
let cmd = match cmd_rx.recv().await {
None => break,