8000 bump imap-rust v3.0.0-alpha.3 · pimalaya/himalaya@36d3cd6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 36d3cd6

Browse files
committed
bump imap-rust v3.0.0-alpha.3
1 parent d41df7d commit 36d3cd6

File tree

6 files changed

+38
-59
lines changed

6 files changed

+38
-59
lines changed

Cargo.lock

+6-42
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ chrono = "0.4.19"
1010
clap = {version = "2.33.3", default-features = false, features = ["suggestions", "color"]}
1111
env_logger = "0.8.3"
1212
error-chain = "0.12.4"
13-
imap = "2.4.0"
13+
imap = "3.0.0-alpha.3"
1414
lettre = "0.10.0-beta.3"
1515
log = "0.4.14"
1616
mailparse = "0.13.1"

src/flag/model.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ impl<'f> Serialize for SerializableFlag<'f> {
1212
where
1313
S: Serializer,
1414
{
15-
serializer.serialize_str(match &self.0 {
15+
serializer.serialize_str(match self.0 {
1616
Flag::Seen => "Seen",
1717
Flag::Answered => "Answered",
1818
Flag::Flagged => "Flagged",
@@ -21,6 +21,7 @@ impl<'f> Serialize for SerializableFlag<'f> {
2121
Flag::Recent => "Recent",
2222
Flag::MayCreate => "MayCreate",
2323
Flag::Custom(cow) => cow,
24+
_ => "Unknown",
2425
})
2526
}
2627
}

src/imap/model.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ impl<'a> ImapConnector<'a> {
119119
.idle()
120120
.and_then(|mut idle| {
121121
idle.set_keepalive(std::time::Duration::new(keepalive, 0));
122-
idle.wait_keepalive()
122+
idle.wait_keepalive_while(|res| {
123+
// TODO: handle response
124+
trace!("idle response: {:?}", res);
125+
false
126+
})
123127
})
124128
.chain_err(|| "Could not start the idle mode")?;
125129

@@ -173,7 +177,11 @@ impl<'a> ImapConnector<'a> {
173177
.idle()
174178
.and_then(|mut idle| {
175179
idle.set_keepalive(std::time::Duration::new(keepalive, 0));
176-
idle.wait_keepalive()
180+
idle.wait_keepalive_while(|res| {
181+
// TODO: handle response
182+
trace!("idle response: {:?}", res);
183+
false
184+
})
177185
})
178186
.chain_err(|| "Could not start the idle mode")?;
179187
app.config.exec_watch_cmds(&app.account)?;
@@ -274,9 +282,11 @@ impl<'a> ImapConnector<'a> {
274282
}
275283
}
276284

277-
pub fn append_msg(&mut self, mbox: &str, msg: &[u8], flags: &[Flag]) -> Result<()> {
285+
pub fn append_msg(&mut self, mbox: &str, msg: &[u8], flags: Vec<Flag>) -> Result<()> {
278286
self.sess
279-
.append_with_flags(mbox, msg, flags)
287+
.append(mbox, msg)
288+
.flags(flags)
289+
.finish()
280290
.chain_err(|| format!("Could not append message to `{}`", mbox))?;
281291

282292
Ok(())

src/msg/cli.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
340340
debug!("sending message…");
341341
let msg = msg.to_sendable_msg()?;
342342
smtp::send(&app.account, &msg)?;
343-
imap_conn.append_msg("Sent", &msg.formatted(), &[Flag::Seen])?;
343+
imap_conn.append_msg("Sent", &msg.formatted(), vec![Flag::Seen])?;
344344
input::remove_draft()?;
345345
app.output.print("Message successfully sent");
346346
break;
@@ -352,7 +352,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
352352
input::PostEditChoice::LocalDraft => break,
353353
input::PostEditChoice::RemoteDraft => {
354354
debug!("saving to draft…");
355-
imap_conn.append_msg("Drafts", &msg.to_vec()?, &[Flag::Seen])?;
355+
imap_conn.append_msg("Drafts", &msg.to_vec()?, vec![Flag::Seen])?;
356356
input::remove_draft()?;
357357
app.output.print("Message successfully saved to Drafts");
358358
break;
@@ -401,7 +401,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
401401
debug!("sending message…");
402402
let msg = msg.to_sendable_msg()?;
403403
smtp::send(&app.account, &msg)?;
404-
imap_conn.append_msg("Sent", &msg.formatted(), &[Flag::Seen])?;
404+
imap_conn.append_msg("Sent", &msg.formatted(), vec![Flag::Seen])?;
405405
imap_conn.add_flags(&app.mbox, uid, "\\Answered")?;
406406
input::remove_draft()?;
407407
app.output.print("Message successfully sent");
@@ -414,7 +414,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
414414
input::PostEditChoice::LocalDraft => break,
415415
input::PostEditChoice::RemoteDraft => {
416416
debug!("saving to draft…");
417-
imap_conn.append_msg("Drafts", &msg.to_vec()?, &[Flag::Seen])?;
417+
imap_conn.append_msg("Drafts", &msg.to_vec()?, vec![Flag::Seen])?;
418418
input::remove_draft()?;
419419
app.output.print("Message successfully saved to Drafts");
420420
break;
@@ -459,7 +459,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
459459
debug!("sending message…");
460460
let msg = msg.to_sendable_msg()?;
461461
smtp::send(&app.account, &msg)?;
462-
imap_conn.append_msg("Sent", &msg.formatted(), &[Flag::Seen])?;
462+
imap_conn.append_msg("Sent", &msg.formatted(), vec![Flag::Seen])?;
463463
input::remove_draft()?;
464464
app.output.print("Message successfully sent");
465465
break;
@@ -471,7 +471,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
471471
input::PostEditChoice::LocalDraft => break,
472472
input::PostEditChoice::RemoteDraft => {
473473
debug!("saving to draft…");
474-
imap_conn.append_msg("Drafts", &msg.to_vec()?, &[Flag::Seen])?;
474+
imap_conn.append_msg("Drafts", &msg.to_vec()?, vec![Flag::Seen])?;
475475
input::remove_draft()?;
476476
app.output.print("Message successfully saved to Drafts");
477477
break;
@@ -548,7 +548,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
548548
let msg = Msg::from(imap_conn.read_msg(&app.mbox, &uid)?);
549549
let mut flags = msg.flags.deref().to_vec();
550550
flags.push(Flag::Seen);
551-
imap_conn.append_msg(target, &msg.raw, &flags)?;
551+
imap_conn.append_msg(target, &msg.raw, flags)?;
552552
debug!("message {} successfully copied to folder `{}`", uid, target);
553553
app.output.print(format!(
554554
"Message {} successfully copied to folder `{}`",
@@ -569,9 +569,9 @@ pub fn msg_matches(app: &App) -> Result<bool> {
569569

570570
let mut imap_conn = ImapConnector::new(&app.account)?;
571571
let msg = Msg::from(imap_conn.read_msg(&app.mbox, &uid)?);
572-
let mut flags = msg.flags.deref().to_vec();
572+
let mut flags = msg.flags.to_vec();
573573
flags.push(Flag::Seen);
574-
imap_conn.append_msg(target, &msg.raw, &flags)?;
574+
imap_conn.append_msg(target, &msg.raw, flags)?;
575575
imap_conn.add_flags(&app.mbox, uid, "\\Seen \\Deleted")?;
576576
debug!("message {} successfully moved to folder `{}`", uid, target);
577577
app.output.print(format!(
@@ -624,7 +624,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
624624
let msg = Msg::from(msg.to_string());
625625
let msg = msg.to_sendable_msg()?;
626626
smtp::send(&app.account, &msg)?;
627-
imap_conn.append_msg("Sent", &msg.formatted(), &[Flag::Seen])?;
627+
imap_conn.append_msg("Sent", &msg.formatted(), vec![Flag::Seen])?;
628628

629629
imap_conn.logout();
630630
return Ok(true);
@@ -636,7 +636,7 @@ pub fn msg_matches(app: &App) -> Result<bool> {
636636
let mut imap_conn = ImapConnector::new(&app.account)?;
637637
let msg = matches.value_of("message").unwrap();
638638
let msg = Msg::from(msg.to_string());
639-
imap_conn.append_msg(&app.mbox, &msg.to_vec()?, &[Flag::Seen])?;
639+
imap_conn.append_msg(&app.mbox, &msg.to_vec()?, vec![Flag::Seen])?;
640640

641641
imap_conn.logout();
642642
return Ok(true);

src/msg/model.rs

+4
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ impl<'m> From<&'m imap::types::Fetch> for Msg<'m> {
235235
flags: Flags::new(fetch.flags()),
236236
subject: envelope
237237
.subject
238+
.as_ref()
238239
.and_then(|subj| rfc2047_decoder::decode(subj).ok())
239240
.unwrap_or_default(),
240241
sender: envelope
@@ -243,14 +244,17 @@ impl<'m> From<&'m imap::types::Fetch> for Msg<'m> {
243244
.and_then(|addrs| addrs.first())
244245
.and_then(|addr| {
245246
addr.name
247+
.as_ref()
246248
.and_then(|name| rfc2047_decoder::decode(name).ok())
247249
.or_else(|| {
248250
let mbox = addr
249251
.mailbox
252+
.as_ref()
250253
.and_then(|mbox| String::from_utf8(mbox.to_vec()).ok())
251254
.unwrap_or(String::from("unknown"));
252255
let host = addr
253256
.host
257+
.as_ref()
254258
.and_then(|host| String::from_utf8(host.to_vec()).ok())
255259
.unwrap_or(String::from("unknown"));
256260
Some(format!("{}@{}", mbox, host))

0 commit comments

Comments
 (0)
0