aboutsummaryrefslogtreecommitdiff
path: root/src/command.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-06-07 13:46:13 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-06-07 13:46:13 +0200
commitcbcc339d50fc2c30e51776c3a60818190ffb4f23 (patch)
tree268938d6c45b1323cea34949c6712f544d9ac00e /src/command.rs
parent93f943aa802163eb47feef592c1504112e4588c5 (diff)
downloadaerogramme-cbcc339d50fc2c30e51776c3a60818190ffb4f23.tar.gz
aerogramme-cbcc339d50fc2c30e51776c3a60818190ffb4f23.zip
Start implementing other endpoints
Diffstat (limited to 'src/command.rs')
-rw-r--r--src/command.rs22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/command.rs b/src/command.rs
index 2ee1a07..9b2f12d 100644
--- a/src/command.rs
+++ b/src/command.rs
@@ -4,11 +4,12 @@ use boitalettres::errors::Error as BalError;
use boitalettres::proto::{Request, Response};
use imap_codec::types::core::{Tag, AString};
use imap_codec::types::response::{Capability, Data};
-use imap_codec::types::mailbox::{Mailbox, ListMailbox};
+use imap_codec::types::mailbox::{Mailbox as MailboxCodec, ListMailbox};
use imap_codec::types::sequence::SequenceSet;
use imap_codec::types::fetch_attributes::MacroOrFetchAttributes;
use crate::mailstore::Mailstore;
+use crate::mailbox::Mailbox;
use crate::service::Session;
pub struct Command {
@@ -43,23 +44,34 @@ impl Command {
};
let mut session = match self.session.lock() {
- Err(_) => return Response::bad("[AUTHENTICATIONFAILED] Unable to acquire mutex."),
+ Err(_) => return Response::bad("[AUTHENTICATIONFAILED] Unable to acquire lock on session."),
Ok(s) => s,
};
session.creds = Some(creds);
+ drop(session);
Response::ok("Logged in")
}
- pub async fn lsub(&self, reference: Mailbox, mailbox_wildcard: ListMailbox) -> Result<Response, BalError> {
+ pub async fn lsub(&self, reference: MailboxCodec, mailbox_wildcard: ListMailbox) -> Result<Response, BalError> {
Response::bad("Not implemented")
}
- pub async fn list(&self, reference: Mailbox, mailbox_wildcard: ListMailbox) -> Result<Response, BalError> {
+ pub async fn list(&self, reference: MailboxCodec, mailbox_wildcard: ListMailbox) -> Result<Response, BalError> {
Response::bad("Not implemented")
}
- pub async fn select(&self, mailbox: Mailbox) -> Result<Response, BalError> {
+ pub async fn select(&self, mailbox: MailboxCodec) -> Result<Response, BalError> {
+
+ let mut session = match self.session.lock() {
+ Err(_) => return Response::no("[SELECTFAILED] Unable to acquire lock on session."),
+ Ok(s) => s,
+ };
+
+ let mb = Mailbox::new(session.creds.as_ref().unwrap(), "TestMailbox".to_string()).unwrap();
+ session.selected = Some(mb);
+ drop(session);
+
Response::bad("Not implemented")
}