Improve SELECT
This commit is contained in:
parent
bdae537fe7
commit
7113809cb7
3 changed files with 16 additions and 3 deletions
|
@ -41,7 +41,9 @@ impl<'a> Command<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.session.creds = Some(creds);
|
self.session.creds = Some(creds);
|
||||||
|
self.session.username = Some(u.clone());
|
||||||
|
|
||||||
|
tracing::info!(username=%u, "connected");
|
||||||
Response::ok("Logged in")
|
Response::ok("Logged in")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,10 +56,20 @@ impl<'a> Command<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn select(&mut self, mailbox: MailboxCodec) -> Result<Response, BalError> {
|
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);
|
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")
|
Response::bad("Not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::uidindex::*;
|
||||||
|
|
||||||
pub struct Mailbox {
|
pub struct Mailbox {
|
||||||
bucket: String,
|
bucket: String,
|
||||||
name: String,
|
pub name: String,
|
||||||
key: Key,
|
key: Key,
|
||||||
|
|
||||||
k2v: K2vClient,
|
k2v: K2vClient,
|
||||||
|
|
|
@ -72,10 +72,11 @@ pub struct Instance {
|
||||||
pub mailstore: Arc<Mailstore>,
|
pub mailstore: Arc<Mailstore>,
|
||||||
pub creds: Option<Credentials>,
|
pub creds: Option<Credentials>,
|
||||||
pub selected: Option<Mailbox>,
|
pub selected: Option<Mailbox>,
|
||||||
|
pub username: Option<String>,
|
||||||
}
|
}
|
||||||
impl Instance {
|
impl Instance {
|
||||||
fn new(mailstore: Arc<Mailstore>, rx: mpsc::Receiver<Message>) -> Self {
|
fn new(mailstore: Arc<Mailstore>, rx: mpsc::Receiver<Message>) -> Self {
|
||||||
Self { mailstore, rx, creds: None, selected: None, }
|
Self { mailstore, rx, creds: None, selected: None, username: None, }
|
||||||
}
|
}
|
||||||
|
|
||||||
//@FIXME add a function that compute the runner's name from its local info
|
//@FIXME add a function that compute the runner's name from its local info
|
||||||
|
|
Loading…
Reference in a new issue