i fucking hate email
This commit is contained in:
parent
22411cf4e3
commit
4c002a1dd3
3 changed files with 38 additions and 2 deletions
|
@ -126,6 +126,16 @@ impl ClientAuthenticated {
|
|||
client_expose!(async execute(cmd: Command) -> Result<ResponseStream>);
|
||||
client_expose!(async has_capability(cap: impl AsRef<str>) -> Result<bool>);
|
||||
|
||||
pub async fn search(&mut self) -> Result<()> {
|
||||
let cmd = Command::Examine;
|
||||
let res = self.execute(cmd).await?;
|
||||
let (done, data) = res.wait().await?;
|
||||
println!("done = {:?}", done);
|
||||
println!("data = {:?}", data);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Runs the LIST command
|
||||
pub async fn list(&mut self) -> Result<Vec<Mailbox>> {
|
||||
let cmd = Command::List(CommandList {
|
||||
|
@ -168,13 +178,18 @@ impl ClientAuthenticated {
|
|||
code: Some(code),
|
||||
..
|
||||
},
|
||||
) => match code {
|
||||
)
|
||||
| Response::Condition(Condition {
|
||||
status: Status::Ok,
|
||||
code: Some(code),
|
||||
..
|
||||
}) => match code {
|
||||
ResponseCode::Unseen(value) => select.unseen = Some(value),
|
||||
ResponseCode::UidNext(value) => select.uid_next = Some(value),
|
||||
ResponseCode::UidValidity(value) => select.uid_validity = Some(value),
|
||||
_ => {}
|
||||
},
|
||||
_ => {}
|
||||
_ => warn!("unknown response {:?}", resp),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,26 @@ fn test_literal() {
|
|||
#[test]
|
||||
fn afl() { let _ = response(Bytes::from(b"* 4544444444 444 ")); }
|
||||
|
||||
#[test]
|
||||
fn test_date() {}
|
||||
|
||||
#[test]
|
||||
fn test_fetch() {
|
||||
use nom::Err;
|
||||
use panorama_proto_common::convert_error;
|
||||
let buf = Bytes::from(b"* 8045 FETCH (UID 8225 ENVELOPE (\"Sun, 21 Mar 2021 18:44:10 -0700\" \"SUBJECT\" ((\"SENDER\" NIL \"sender\" \"example.com\")) ((\"SENDER\" NIL \"sender\" \"example.com\")) ((\"noreply\" NIL \"noreply\" \"example.com\")) ((\"NAME\" NIL \"user\" \"gmail.com\")) NIL NIL NIL \"<HASH-99c91810@example.com>\") FLAGS () INTERNALDATE \"22-Mar-2021 01:44:12 +0000\" RFC822.SIZE 13503)\r\n".to_vec());
|
||||
let res = response(buf.clone());
|
||||
let res = match res {
|
||||
Ok((_, res)) => res,
|
||||
Err(Err::Error(err)) | Err(Err::Failure(err)) => {
|
||||
println!("code: {}", convert_error(buf, err));
|
||||
panic!()
|
||||
}
|
||||
_ => panic!(),
|
||||
};
|
||||
assert!(matches!(res, Response::Expunge(2)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_capabilities() {
|
||||
assert_eq!(
|
||||
|
|
|
@ -55,6 +55,7 @@ pub async fn open(config: &Config, store_name: impl AsRef<str>) -> Result<Opened
|
|||
|
||||
let select = client.select("INBOX").await?;
|
||||
println!("select: {:?}", select);
|
||||
|
||||
use futures::stream::StreamExt;
|
||||
use panorama_imap::proto::command::FetchItems;
|
||||
let mut result = client.uid_fetch(&[8225], &[], FetchItems::All).await?;
|
||||
|
|
Loading…
Reference in a new issue