aboutsummaryrefslogtreecommitdiff
path: root/src/command.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-06-13 12:25:19 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-06-13 12:25:19 +0200
commit7113809cb7b9f0e73d942b295e693675301d1565 (patch)
tree801d5a201507f9b8721b21048615689b85edfcd7 /src/command.rs
parentbdae537fe7dbf9c7fc731af3f427400055ea03cf (diff)
downloadaerogramme-7113809cb7b9f0e73d942b295e693675301d1565.tar.gz
aerogramme-7113809cb7b9f0e73d942b295e693675301d1565.zip
Improve SELECT
Diffstat (limited to 'src/command.rs')
-rw-r--r--src/command.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/command.rs b/src/command.rs
index a9b39e4..0b576b2 100644
--- a/src/command.rs
+++ b/src/command.rs
@@ -41,7 +41,9 @@ impl<'a> Command<'a> {
};
self.session.creds = Some(creds);
+ self.session.username = Some(u.clone());
+ tracing::info!(username=%u, "connected");
Response::ok("Logged in")
}
@@ -54,10 +56,20 @@ impl<'a> Command<'a> {
}
pub async fn select(&mut self, mailbox: MailboxCodec) -> Result<Response, BalError> {
+ let (name, creds) = match (String::try_from(mailbox), self.session.creds.as_ref()) {
+ (Ok(n), Some(c)) => (n, c),
+ (_, None) => return Response::no("You must be connected to use SELECT"),
+ (Err(e), _) => {
+ tracing::warn!("Unable to decode mailbox name: {:#?}", e);
+ return Response::bad("Unable to decode mailbox name")
+ },
+ };
- let mb = Mailbox::new(self.session.creds.as_ref().unwrap(), "TestMailbox".to_string()).unwrap();
+ let mb = Mailbox::new(creds, name.clone()).unwrap();
self.session.selected = Some(mb);
+ let user = self.session.username.as_ref().unwrap();
+ tracing::info!(username=%user, mailbox=%name, "mailbox-selected");
Response::bad("Not implemented")
}