mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-08 10:35:13 +00:00
implement notmuch get_msg
This commit is contained in:
parent
8766d8862a
commit
7093cfc715
|
@ -1,16 +1,14 @@
|
||||||
use std::convert::TryInto;
|
use std::{convert::TryInto, fs};
|
||||||
|
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
backends::Backend,
|
backends::{Backend, NotmuchEnvelopes},
|
||||||
config::{AccountConfig, NotmuchBackendConfig},
|
config::{AccountConfig, NotmuchBackendConfig},
|
||||||
mbox::Mboxes,
|
mbox::Mboxes,
|
||||||
msg::{Envelopes, Msg},
|
msg::{Envelopes, Msg},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::NotmuchEnvelopes;
|
|
||||||
|
|
||||||
pub struct NotmuchBackend<'a> {
|
pub struct NotmuchBackend<'a> {
|
||||||
account_config: &'a AccountConfig,
|
account_config: &'a AccountConfig,
|
||||||
db: notmuch::Database,
|
db: notmuch::Database,
|
||||||
|
@ -121,8 +119,18 @@ impl<'a> Backend<'a> for NotmuchBackend<'a> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_msg(&mut self, _mbox: &str, _id: &str) -> Result<Msg> {
|
fn get_msg(&mut self, _mbox: &str, id: &str) -> Result<Msg> {
|
||||||
unimplemented!();
|
let msg_filepath = self
|
||||||
|
.db
|
||||||
|
.find_message(id)
|
||||||
|
.context(format!("cannot find notmuch message {:?}", id))?
|
||||||
|
.ok_or_else(|| anyhow!("cannot find notmuch message {:?}", id))?
|
||||||
|
.filename()
|
||||||
|
.to_owned();
|
||||||
|
let raw_msg = fs::read(&msg_filepath)
|
||||||
|
.context(format!("cannot read message from file {:?}", msg_filepath))?;
|
||||||
|
let msg = Msg::from_parsed_mail(mailparse::parse_mail(&raw_msg)?, &self.account_config)?;
|
||||||
|
Ok(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn copy_msg(&mut self, _mbox_src: &str, _mbox_dst: &str, _id: &str) -> Result<()> {
|
fn copy_msg(&mut self, _mbox_src: &str, _mbox_dst: &str, _id: &str) -> Result<()> {
|
||||||
|
|
Loading…
Reference in a new issue