mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-16 20:57:53 +08:00
bump imap-rust v3.0.0-alpha.3
This commit is contained in:
+2
-1
@@ -12,7 +12,7 @@ impl<'f> Serialize for SerializableFlag<'f> {
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
serializer.serialize_str(match &self.0 {
|
||||
serializer.serialize_str(match self.0 {
|
||||
Flag::Seen => "Seen",
|
||||
Flag::Answered => "Answered",
|
||||
Flag::Flagged => "Flagged",
|
||||
@@ -21,6 +21,7 @@ impl<'f> Serialize for SerializableFlag<'f> {
|
||||
Flag::Recent => "Recent",
|
||||
Flag::MayCreate => "MayCreate",
|
||||
Flag::Custom(cow) => cow,
|
||||
_ => "Unknown",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+14
-4
@@ -119,7 +119,11 @@ impl<'a> ImapConnector<'a> {
|
||||
.idle()
|
||||
.and_then(|mut idle| {
|
||||
idle.set_keepalive(std::time::Duration::new(keepalive, 0));
|
||||
idle.wait_keepalive()
|
||||
idle.wait_keepalive_while(|res| {
|
||||
// TODO: handle response
|
||||
trace!("idle response: {:?}", res);
|
||||
false
|
||||
})
|
||||
})
|
||||
.chain_err(|| "Could not start the idle mode")?;
|
||||
|
||||
@@ -173,7 +177,11 @@ impl<'a> ImapConnector<'a> {
|
||||
.idle()
|
||||
.and_then(|mut idle| {
|
||||
idle.set_keepalive(std::time::Duration::new(keepalive, 0));
|
||||
idle.wait_keepalive()
|
||||
idle.wait_keepalive_while(|res| {
|
||||
// TODO: handle response
|
||||
trace!("idle response: {:?}", res);
|
||||
false
|
||||
})
|
||||
})
|
||||
.chain_err(|| "Could not start the idle mode")?;
|
||||
app.config.exec_watch_cmds(&app.account)?;
|
||||
@@ -274,9 +282,11 @@ impl<'a> ImapConnector<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn append_msg(&mut self, mbox: &str, msg: &[u8], flags: &[Flag]) -> Result<()> {
|
||||
pub fn append_msg(&mut self, mbox: &str, msg: &[u8], flags: Vec<Flag>) -> Result<()> {
|
||||
self.sess
|
||||
.append_with_flags(mbox, msg, flags)
|
||||
.append(mbox, msg)
|
||||
.flags(flags)
|
||||
.finish()
|
||||
.chain_err(|| format!("Could not append message to `{}`", mbox))?;
|
||||
|
||||
Ok(())
|
||||
|
||||
+11
-11
@@ -340,7 +340,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
|
||||
debug!("sending message…");
|
||||
let msg = msg.to_sendable_msg()?;
|
||||
smtp::send(&app.account, &msg)?;
|
||||
imap_conn.append_msg("Sent", &msg.formatted(), &[Flag::Seen])?;
|
||||
imap_conn.append_msg("Sent", &msg.formatted(), vec![Flag::Seen])?;
|
||||
input::remove_draft()?;
|
||||
app.output.print("Message successfully sent");
|
||||
break;
|
||||
@@ -352,7 +352,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
|
||||
input::PostEditChoice::LocalDraft => break,
|
||||
input::PostEditChoice::RemoteDraft => {
|
||||
debug!("saving to draft…");
|
||||
imap_conn.append_msg("Drafts", &msg.to_vec()?, &[Flag::Seen])?;
|
||||
imap_conn.append_msg("Drafts", &msg.to_vec()?, vec![Flag::Seen])?;
|
||||
input::remove_draft()?;
|
||||
app.output.print("Message successfully saved to Drafts");
|
||||
break;
|
||||
@@ -401,7 +401,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
|
||||
debug!("sending message…");
|
||||
let msg = msg.to_sendable_msg()?;
|
||||
smtp::send(&app.account, &msg)?;
|
||||
imap_conn.append_msg("Sent", &msg.formatted(), &[Flag::Seen])?;
|
||||
imap_conn.append_msg("Sent", &msg.formatted(), vec![Flag::Seen])?;
|
||||
imap_conn.add_flags(&app.mbox, uid, "\\Answered")?;
|
||||
input::remove_draft()?;
|
||||
app.output.print("Message successfully sent");
|
||||
@@ -414,7 +414,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
|
||||
input::PostEditChoice::LocalDraft => break,
|
||||
input::PostEditChoice::RemoteDraft => {
|
||||
debug!("saving to draft…");
|
||||
imap_conn.append_msg("Drafts", &msg.to_vec()?, &[Flag::Seen])?;
|
||||
imap_conn.append_msg("Drafts", &msg.to_vec()?, vec![Flag::Seen])?;
|
||||
input::remove_draft()?;
|
||||
app.output.print("Message successfully saved to Drafts");
|
||||
break;
|
||||
@@ -459,7 +459,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
|
||||
debug!("sending message…");
|
||||
let msg = msg.to_sendable_msg()?;
|
||||
smtp::send(&app.account, &msg)?;
|
||||
imap_conn.append_msg("Sent", &msg.formatted(), &[Flag::Seen])?;
|
||||
imap_conn.append_msg("Sent", &msg.formatted(), vec![Flag::Seen])?;
|
||||
input::remove_draft()?;
|
||||
app.output.print("Message successfully sent");
|
||||
break;
|
||||
@@ -471,7 +471,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
|
||||
input::PostEditChoice::LocalDraft => break,
|
||||
input::PostEditChoice::RemoteDraft => {
|
||||
debug!("saving to draft…");
|
||||
imap_conn.append_msg("Drafts", &msg.to_vec()?, &[Flag::Seen])?;
|
||||
imap_conn.append_msg("Drafts", &msg.to_vec()?, vec![Flag::Seen])?;
|
||||
input::remove_draft()?;
|
||||
app.output.print("Message successfully saved to Drafts");
|
||||
break;
|
||||
@@ -548,7 +548,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
|
||||
let msg = Msg::from(imap_conn.read_msg(&app.mbox, &uid)?);
|
||||
let mut flags = msg.flags.deref().to_vec();
|
||||
flags.push(Flag::Seen);
|
||||
imap_conn.append_msg(target, &msg.raw, &flags)?;
|
||||
imap_conn.append_msg(target, &msg.raw, flags)?;
|
||||
debug!("message {} successfully copied to folder `{}`", uid, target);
|
||||
app.output.print(format!(
|
||||
"Message {} successfully copied to folder `{}`",
|
||||
@@ -569,9 +569,9 @@ pub fn msg_matches(app: &App) -> Result<bool> {
|
||||
|
||||
let mut imap_conn = ImapConnector::new(&app.account)?;
|
||||
let msg = Msg::from(imap_conn.read_msg(&app.mbox, &uid)?);
|
||||
let mut flags = msg.flags.deref().to_vec();
|
||||
let mut flags = msg.flags.to_vec();
|
||||
flags.push(Flag::Seen);
|
||||
imap_conn.append_msg(target, &msg.raw, &flags)?;
|
||||
imap_conn.append_msg(target, &msg.raw, flags)?;
|
||||
imap_conn.add_flags(&app.mbox, uid, "\\Seen \\Deleted")?;
|
||||
debug!("message {} successfully moved to folder `{}`", uid, target);
|
||||
app.output.print(format!(
|
||||
@@ -624,7 +624,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
|
||||
let msg = Msg::from(msg.to_string());
|
||||
let msg = msg.to_sendable_msg()?;
|
||||
smtp::send(&app.account, &msg)?;
|
||||
imap_conn.append_msg("Sent", &msg.formatted(), &[Flag::Seen])?;
|
||||
imap_conn.append_msg("Sent", &msg.formatted(), vec![Flag::Seen])?;
|
||||
|
||||
imap_conn.logout();
|
||||
return Ok(true);
|
||||
@@ -636,7 +636,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
|
||||
let mut imap_conn = ImapConnector::new(&app.account)?;
|
||||
let msg = matches.value_of("message").unwrap();
|
||||
let msg = Msg::from(msg.to_string());
|
||||
imap_conn.append_msg(&app.mbox, &msg.to_vec()?, &[Flag::Seen])?;
|
||||
imap_conn.append_msg(&app.mbox, &msg.to_vec()?, vec![Flag::Seen])?;
|
||||
|
||||
imap_conn.logout();
|
||||
return Ok(true);
|
||||
|
||||
@@ -235,6 +235,7 @@ impl<'m> From<&'m imap::types::Fetch> for Msg<'m> {
|
||||
flags: Flags::new(fetch.flags()),
|
||||
subject: envelope
|
||||
.subject
|
||||
.as_ref()
|
||||
.and_then(|subj| rfc2047_decoder::decode(subj).ok())
|
||||
.unwrap_or_default(),
|
||||
sender: envelope
|
||||
@@ -243,14 +244,17 @@ impl<'m> From<&'m imap::types::Fetch> for Msg<'m> {
|
||||
.and_then(|addrs| addrs.first())
|
||||
.and_then(|addr| {
|
||||
addr.name
|
||||
.as_ref()
|
||||
.and_then(|name| rfc2047_decoder::decode(name).ok())
|
||||
.or_else(|| {
|
||||
let mbox = addr
|
||||
.mailbox
|
||||
.as_ref()
|
||||
.and_then(|mbox| String::from_utf8(mbox.to_vec()).ok())
|
||||
.unwrap_or(String::from("unknown"));
|
||||
let host = addr
|
||||
.host
|
||||
.as_ref()
|
||||
.and_then(|host| String::from_utf8(host.to_vec()).ok())
|
||||
.unwrap_or(String::from("unknown"));
|
||||
Some(format!("{}@{}", mbox, host))
|
||||
|
||||
Reference in New Issue
Block a user