diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-10-09 11:56:50 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-10-11 16:53:04 +0300 |
commit | 3ec1ecb34989cc942192fd6ea471a1f0bbd9dd71 (patch) | |
tree | 993b5b5737f3e6edad32511da879b6b43a73bae8 /src/components/mail/listing.rs | |
parent | afe7eed9ef4f52228257cd6399bf9c4d4dcc689a (diff) |
Add import mail action
Diffstat (limited to 'src/components/mail/listing.rs')
-rw-r--r-- | src/components/mail/listing.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/components/mail/listing.rs b/src/components/mail/listing.rs index 7baa2cda..e347e86b 100644 --- a/src/components/mail/listing.rs +++ b/src/components/mail/listing.rs @@ -750,6 +750,28 @@ impl Component for Listing { self.component.set_style(IndexStyle::Conversations); return true; } + Action::Listing(ListingAction::Import(file_path, mailbox_path)) => { + let account = &mut context.accounts[self.cursor_pos.0]; + if let Err(err) = account + .mailbox_by_path(&mailbox_path) + .and_then(|mailbox_hash| { + Ok(( + std::fs::read(&file_path).chain_err_summary(|| { + format!("Could not read {}", file_path.display()) + })?, + mailbox_hash, + )) + }) + .and_then(|(bytes, mailbox_hash)| { + account.save(&bytes, mailbox_hash, None) + }) + { + context.replies.push_back(UIEvent::StatusEvent( + StatusEvent::DisplayMessage(err.to_string()), + )); + } + return true; + } Action::Listing(a @ ListingAction::SetSeen) | Action::Listing(a @ ListingAction::SetUnseen) | Action::Listing(a @ ListingAction::Delete) |