diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-01-03 12:59:27 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-01-03 12:59:27 +0100 |
commit | 7b4556c190656537e473deb435124d030948298b (patch) | |
tree | 1c448551ca289738cb0ae3f4c3a21d6d53353ee8 | |
parent | 2e0fc1e4f0f03b7d7677bf7c0ff2076e2e2599aa (diff) |
Add helper functions to check whether a mail is passed, replied,...
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | lib/domain/libimagmail/src/mail.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/domain/libimagmail/src/mail.rs b/lib/domain/libimagmail/src/mail.rs index 6e5f2876..db75b5d3 100644 --- a/lib/domain/libimagmail/src/mail.rs +++ b/lib/domain/libimagmail/src/mail.rs @@ -46,6 +46,12 @@ pub trait Mail : RefFassade { fn get_in_reply_to(&self, refconfig: &RefConfig) -> Result<Option<MessageId>>; fn flags(&self, refconfig: &RefConfig) -> Result<Vec<MailFlag>>; + fn is_passed(&self, refconfig: &RefConfig) -> Result<bool>; + fn is_replied(&self, refconfig: &RefConfig) -> Result<bool>; + fn is_seen(&self, refconfig: &RefConfig) -> Result<bool>; + fn is_trashed(&self, refconfig: &RefConfig) -> Result<bool>; + fn is_draft(&self, refconfig: &RefConfig) -> Result<bool>; + fn is_flagged(&self, refconfig: &RefConfig) -> Result<bool>; } impl Mail for Entry { @@ -164,6 +170,37 @@ impl Mail for Entry { } } + /// Check whether the mail is passed + fn is_passed(&self, refconfig: &RefConfig) -> Result<bool> { + self.flags(refconfig).map(|fs| fs.into_iter().any(|f| MailFlag::Passed == f)) + } + + /// Check whether the mail is replied + fn is_replied(&self, refconfig: &RefConfig) -> Result<bool> { + self.flags(refconfig).map(|fs| fs.into_iter().any(|f| MailFlag::Replied == f)) + } + + /// Check whether the mail is seen + fn is_seen(&self, refconfig: &RefConfig) -> Result<bool> { + self.flags(refconfig).map(|fs| fs.into_iter().any(|f| MailFlag::Seen == f)) + } + + /// Check whether the mail is trashed + fn is_trashed(&self, refconfig: &RefConfig) -> Result<bool> { + self.flags(refconfig).map(|fs| fs.into_iter().any(|f| MailFlag::Trashed == f)) + } + + /// Check whether the mail is draft + fn is_draft(&self, refconfig: &RefConfig) -> Result<bool> { + self.flags(refconfig).map(|fs| fs.into_iter().any(|f| MailFlag::Draft == f)) + } + + /// Check whether the mail is flagged + fn is_flagged(&self, refconfig: &RefConfig) -> Result<bool> { + self.flags(refconfig).map(|fs| fs.into_iter().any(|f| MailFlag::Flagged == f)) + } + + } #[derive(Debug)] |