Generate missing message_id from byte hash
parent
e4760e4d25
commit
4e5721563e
|
@ -27,9 +27,9 @@ pub mod pager;
|
|||
use pager::PagerSettings;
|
||||
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::hash::Hasher;
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::hash::Hasher;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
|
|
|
@ -33,6 +33,8 @@ use std::option::Option;
|
|||
use std::string::String;
|
||||
use std::sync::Arc;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::hash::Hasher;
|
||||
|
||||
use chrono;
|
||||
use chrono::TimeZone;
|
||||
|
@ -327,6 +329,11 @@ impl Envelope {
|
|||
self.set_datetime(d);
|
||||
}
|
||||
}
|
||||
if self.message_id.is_none() {
|
||||
let mut h = DefaultHasher::new();
|
||||
h.write(&self.bytes());
|
||||
self.set_message_id(format!("<{:x}>", h.finish()).as_bytes());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
pub fn date(&self) -> u64 {
|
||||
|
|
|
@ -122,9 +122,6 @@ fn build_collection(
|
|||
let x_index; /* x's index in threads */
|
||||
let m_id = x.message_id_raw().into_owned();
|
||||
let m_id = Cow::from(m_id);
|
||||
/* TODO: Check for missing Message-ID.
|
||||
* Solutions: generate a hidden one
|
||||
*/
|
||||
if id_table.contains_key(&m_id) {
|
||||
let t = id_table[&m_id];
|
||||
/* the already existing Container should be empty, since we're
|
||||
|
|
|
@ -229,7 +229,6 @@ impl Component for MailView {
|
|||
} else {
|
||||
self.pager.as_mut().map(|p| p.cursor_pos())
|
||||
};
|
||||
// TODO: pass string instead of envelope
|
||||
self.pager = Some(Pager::from_buf(buf, cursor_pos));
|
||||
self.dirty = false;
|
||||
}
|
||||
|
@ -244,7 +243,6 @@ impl Component for MailView {
|
|||
self.cmd_buf.clear();
|
||||
}
|
||||
UIEventType::Input(Key::Char(c)) if c >= '0' && c <= '9' => {
|
||||
//TODO:this should be an Action
|
||||
self.cmd_buf.push(c);
|
||||
}
|
||||
UIEventType::Input(Key::Char('r')) if self.mode == ViewMode::Normal || self.mode == ViewMode::Raw => {
|
||||
|
@ -256,14 +254,12 @@ impl Component for MailView {
|
|||
self.dirty = true;
|
||||
}
|
||||
UIEventType::Input(Key::Char('r')) if self.mode.is_attachment() => {
|
||||
//TODO:one quit shortcut?
|
||||
self.mode = ViewMode::Normal;
|
||||
self.dirty = true;
|
||||
}
|
||||
UIEventType::Input(Key::Char('a'))
|
||||
if self.cmd_buf.len() > 0 && self.mode == ViewMode::Normal =>
|
||||
{
|
||||
//TODO:this should be an Action
|
||||
let lidx = self.cmd_buf.parse::<usize>().unwrap();
|
||||
self.cmd_buf.clear();
|
||||
|
||||
|
@ -336,8 +332,6 @@ impl Component for MailView {
|
|||
UIEventType::Input(Key::Char('g'))
|
||||
if self.cmd_buf.len() > 0 && self.mode == ViewMode::Url =>
|
||||
{
|
||||
//TODO:this should be an Action
|
||||
|
||||
let lidx = self.cmd_buf.parse::<usize>().unwrap();
|
||||
self.cmd_buf.clear();
|
||||
let url = {
|
||||
|
@ -381,7 +375,6 @@ impl Component for MailView {
|
|||
.expect("Failed to start xdg_open");
|
||||
}
|
||||
UIEventType::Input(Key::Char('u')) => {
|
||||
//TODO:this should be an Action
|
||||
match self.mode {
|
||||
ViewMode::Normal => self.mode = ViewMode::Url,
|
||||
ViewMode::Url => self.mode = ViewMode::Normal,
|
||||
|
|
|
@ -384,15 +384,10 @@ impl<W: Write> State<W> {
|
|||
}
|
||||
/// Convert user commands to actions/method calls.
|
||||
fn parse_command(&mut self, cmd: String) {
|
||||
//TODO: Make ex mode useful
|
||||
|
||||
let result = parse_command(&cmd.as_bytes()).to_full_result();
|
||||
|
||||
if let Ok(v) = result {
|
||||
eprintln!("result is {:?}", v);
|
||||
self.rcv_event(UIEvent { id: 0, event_type: UIEventType::Action(v) });
|
||||
;
|
||||
//self.refresh_mailbox(0, v);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue