mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-08 18:45:13 +00:00
notify cannot get body (#233)
* imap: fix notify cmd * doc: update changelog
This commit is contained in:
parent
f0b2fd788d
commit
eaa83b71ef
|
@ -9,7 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Error on empty subject [#229]
|
- Error when receiving notification from `notify` command [#228]
|
||||||
|
|
||||||
|
### Change
|
||||||
|
|
||||||
|
- Remove error when empty subject [#229]
|
||||||
|
|
||||||
## [0.5.0] - 2021-10-10
|
## [0.5.0] - 2021-10-10
|
||||||
|
|
||||||
|
@ -337,4 +341,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
[#199]: https://github.com/soywod/himalaya/issues/199
|
[#199]: https://github.com/soywod/himalaya/issues/199
|
||||||
[#205]: https://github.com/soywod/himalaya/issues/205
|
[#205]: https://github.com/soywod/himalaya/issues/205
|
||||||
[#215]: https://github.com/soywod/himalaya/issues/215
|
[#215]: https://github.com/soywod/himalaya/issues/215
|
||||||
|
[#228]: https://github.com/soywod/himalaya/issues/228
|
||||||
[#229]: https://github.com/soywod/himalaya/issues/229
|
[#229]: https://github.com/soywod/himalaya/issues/229
|
||||||
|
|
|
@ -111,7 +111,7 @@ impl Config {
|
||||||
let subject = subject.as_ref();
|
let subject = subject.as_ref();
|
||||||
let sender = sender.as_ref();
|
let sender = sender.as_ref();
|
||||||
|
|
||||||
let default_cmd = format!(r#"notify-send "📫 {}" "{}""#, sender, subject);
|
let default_cmd = format!(r#"notify-send "New message from {}" "{}""#, sender, subject);
|
||||||
let cmd = self
|
let cmd = self
|
||||||
.notify_cmd
|
.notify_cmd
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
|
@ -14,7 +14,7 @@ use std::{
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{Account, Config},
|
config::{Account, Config},
|
||||||
domain::{Envelopes, Flags, Mbox, Mboxes, Msg, RawEnvelopes, RawMboxes},
|
domain::{Envelope, Envelopes, Flags, Mbox, Mboxes, Msg, RawEnvelopes, RawMboxes},
|
||||||
};
|
};
|
||||||
|
|
||||||
type ImapSession = imap::Session<TlsStream<TcpStream>>;
|
type ImapSession = imap::Session<TlsStream<TcpStream>>;
|
||||||
|
@ -284,21 +284,16 @@ impl<'a> ImapServiceInterface<'a> for ImapService<'a> {
|
||||||
.join(",");
|
.join(",");
|
||||||
let fetches = self
|
let fetches = self
|
||||||
.sess()?
|
.sess()?
|
||||||
.uid_fetch(uids, "(ENVELOPE)")
|
.uid_fetch(uids, "(UID ENVELOPE)")
|
||||||
.context("cannot fetch new messages enveloppe")?;
|
.context("cannot fetch new messages enveloppe")?;
|
||||||
|
|
||||||
for fetch in fetches.iter() {
|
for fetch in fetches.iter() {
|
||||||
let msg = Msg::try_from(fetch)?;
|
let msg = Envelope::try_from(fetch)?;
|
||||||
let uid = fetch.uid.ok_or_else(|| {
|
let uid = fetch.uid.ok_or_else(|| {
|
||||||
anyhow!("cannot retrieve message {}'s UID", fetch.message)
|
anyhow!("cannot retrieve message {}'s UID", fetch.message)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let from = msg
|
let from = msg.sender.to_owned().into();
|
||||||
.from
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|addrs| addrs.iter().next())
|
|
||||||
.map(|addr| addr.to_string())
|
|
||||||
.unwrap_or(String::from("unknown"));
|
|
||||||
config.run_notify_cmd(&msg.subject, &from)?;
|
config.run_notify_cmd(&msg.subject, &from)?;
|
||||||
|
|
||||||
debug!("notify message: {}", uid);
|
debug!("notify message: {}", uid);
|
||||||
|
@ -350,7 +345,7 @@ impl<'a> ImapServiceInterface<'a> for ImapService<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_flags(&mut self, seq_range: &str, flags: &Flags) -> Result<()> {
|
fn add_flags(&mut self, seq_range: &str, flags: &Flags) -> Result<()> {
|
||||||
let mbox = self.mbox.to_owned();
|
let mbox = self.mbox;
|
||||||
let flags: String = flags.to_string();
|
let flags: String = flags.to_string();
|
||||||
self.sess()?
|
self.sess()?
|
||||||
.select(&mbox.name)
|
.select(&mbox.name)
|
||||||
|
@ -361,25 +356,25 @@ impl<'a> ImapServiceInterface<'a> for ImapService<'a> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_flags(&mut self, uid_seq: &str, flags: &Flags) -> Result<()> {
|
fn set_flags(&mut self, seq_range: &str, flags: &Flags) -> Result<()> {
|
||||||
let mbox = self.mbox.to_owned();
|
let mbox = self.mbox;
|
||||||
self.sess()?
|
self.sess()?
|
||||||
.select(&mbox.name)
|
.select(&mbox.name)
|
||||||
.context(format!(r#"cannot select mailbox "{}""#, self.mbox.name))?;
|
.context(format!(r#"cannot select mailbox "{}""#, self.mbox.name))?;
|
||||||
self.sess()?
|
self.sess()?
|
||||||
.store(uid_seq, format!("FLAGS ({})", flags))
|
.store(seq_range, format!("FLAGS ({})", flags))
|
||||||
.context(format!(r#"cannot set flags "{}""#, &flags))?;
|
.context(format!(r#"cannot set flags "{}""#, &flags))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_flags(&mut self, uid_seq: &str, flags: &Flags) -> Result<()> {
|
fn remove_flags(&mut self, seq_range: &str, flags: &Flags) -> Result<()> {
|
||||||
let mbox = self.mbox.to_owned();
|
let mbox = self.mbox;
|
||||||
let flags = flags.to_string();
|
let flags = flags.to_string();
|
||||||
self.sess()?
|
self.sess()?
|
||||||
.select(&mbox.name)
|
.select(&mbox.name)
|
||||||
.context(format!(r#"cannot select mailbox "{}""#, self.mbox.name))?;
|
.context(format!(r#"cannot select mailbox "{}""#, self.mbox.name))?;
|
||||||
self.sess()?
|
self.sess()?
|
||||||
.store(uid_seq, format!("-FLAGS ({})", flags))
|
.store(seq_range, format!("-FLAGS ({})", flags))
|
||||||
.context(format!(r#"cannot remove flags "{}""#, &flags))?;
|
.context(format!(r#"cannot remove flags "{}""#, &flags))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue