melib/email: add flags arg to Mail::new
parent
d57dd9c98e
commit
be57b65dae
|
@ -94,9 +94,9 @@ impl Deref for Mail {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Mail {
|
impl Mail {
|
||||||
pub fn new(bytes: Vec<u8>) -> Result<Self> {
|
pub fn new(bytes: Vec<u8>, flags: Option<Flag>) -> Result<Self> {
|
||||||
Ok(Mail {
|
Ok(Mail {
|
||||||
envelope: Envelope::from_bytes(&bytes, None)?,
|
envelope: Envelope::from_bytes(&bytes, flags)?,
|
||||||
bytes,
|
bytes,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,7 +362,7 @@ impl fmt::Display for Attachment {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self.content_type {
|
match self.content_type {
|
||||||
ContentType::MessageRfc822 => {
|
ContentType::MessageRfc822 => {
|
||||||
match Mail::new(self.body.display_bytes(&self.raw).to_vec()) {
|
match Mail::new(self.body.display_bytes(&self.raw).to_vec(), None) {
|
||||||
Ok(wrapper) => write!(
|
Ok(wrapper) => write!(
|
||||||
f,
|
f,
|
||||||
"message/rfc822: {} - {} - {}",
|
"message/rfc822: {} - {} - {}",
|
||||||
|
|
|
@ -309,7 +309,7 @@ fn run_app(opt: Opt) -> Result<()> {
|
||||||
if let Some(SubCommand::View { path }) = opt.subcommand {
|
if let Some(SubCommand::View { path }) = opt.subcommand {
|
||||||
let bytes = std::fs::read(&path)
|
let bytes = std::fs::read(&path)
|
||||||
.chain_err_summary(|| format!("Could not read from `{}`", path.display()))?;
|
.chain_err_summary(|| format!("Could not read from `{}`", path.display()))?;
|
||||||
let wrapper = Mail::new(bytes)
|
let wrapper = Mail::new(bytes, Some(Flag::SEEN))
|
||||||
.chain_err_summary(|| format!("Could not parse `{}`", path.display()))?;
|
.chain_err_summary(|| format!("Could not parse `{}`", path.display()))?;
|
||||||
state = State::new(
|
state = State::new(
|
||||||
Some(Settings::without_accounts().unwrap_or_default()),
|
Some(Settings::without_accounts().unwrap_or_default()),
|
||||||
|
|
|
@ -481,20 +481,25 @@ impl MailView {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
match u.content_type() {
|
match u.content_type() {
|
||||||
ContentType::MessageRfc822 => match Mail::new(u.body().to_vec()) {
|
ContentType::MessageRfc822 => {
|
||||||
Ok(wrapper) => {
|
match Mail::new(u.body().to_vec(), Some(Flag::SEEN)) {
|
||||||
context
|
Ok(wrapper) => {
|
||||||
.replies
|
context.replies.push_back(UIEvent::Action(Tab(New(Some(
|
||||||
.push_back(UIEvent::Action(Tab(New(Some(Box::new(
|
Box::new(EnvelopeView::new(
|
||||||
EnvelopeView::new(wrapper, None, None, self.coordinates.0),
|
wrapper,
|
||||||
))))));
|
None,
|
||||||
|
None,
|
||||||
|
self.coordinates.0,
|
||||||
|
)),
|
||||||
|
)))));
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
context.replies.push_back(UIEvent::StatusEvent(
|
||||||
|
StatusEvent::DisplayMessage(format!("{}", e)),
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
}
|
||||||
context.replies.push_back(UIEvent::StatusEvent(
|
|
||||||
StatusEvent::DisplayMessage(format!("{}", e)),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
ContentType::Text { .. } | ContentType::PGPSignature => {
|
ContentType::Text { .. } | ContentType::PGPSignature => {
|
||||||
self.mode = ViewMode::Attachment(lidx);
|
self.mode = ViewMode::Attachment(lidx);
|
||||||
|
|
Loading…
Reference in New Issue