aboutsummaryrefslogtreecommitdiff
path: root/src/command.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-06-07 12:57:24 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-06-07 12:57:24 +0200
commitc03be0a8c335c462bcc2f171145aef779a652736 (patch)
tree69a423fb52e6a384a94f03341db679425094687c /src/command.rs
parentb82df13082869dc4d455e15c2955e20de0b55675 (diff)
downloadaerogramme-c03be0a8c335c462bcc2f171145aef779a652736.tar.gz
aerogramme-c03be0a8c335c462bcc2f171145aef779a652736.zip
Implement a Mutex
Diffstat (limited to 'src/command.rs')
-rw-r--r--src/command.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/command.rs b/src/command.rs
index 56291ad..24c452b 100644
--- a/src/command.rs
+++ b/src/command.rs
@@ -1,4 +1,4 @@
-use std::sync::Arc;
+use std::sync::{Arc, Mutex};
use boitalettres::errors::Error as BalError;
use boitalettres::proto::{Request, Response};
@@ -6,14 +6,16 @@ use imap_codec::types::core::AString;
use imap_codec::types::response::{Capability, Data};
use crate::mailstore;
+use crate::service;
pub struct Command {
mailstore: Arc<mailstore::Mailstore>,
+ session: Arc<Mutex<service::Session>>,
}
impl Command {
- pub fn new(mailstore: Arc<mailstore::Mailstore>) -> Self {
- Self { mailstore }
+ pub fn new(mailstore: Arc<mailstore::Mailstore>, session: Arc<Mutex<service::Session>>) -> Self {
+ Self { mailstore, session }
}
pub async fn capability(self) -> Result<Response, BalError> {
@@ -36,6 +38,12 @@ impl Command {
Ok(c) => c,
};
+ let mut session = match self.session.lock() {
+ Err(_) => return Response::bad("[AUTHENTICATIONFAILED] Unable to acquire mutex."),
+ Ok(s) => s,
+ };
+ session.creds = Some(creds);
+
Response::ok("Logged in")
}
}