summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2018-08-05 16:37:53 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-06-10 19:40:26 +0300
commit4e5721563e8dbc276ee2f7119c146c2fdeacdb14 (patch)
tree80353340b48c3c8935deb817a3deb9199687443d
parente4760e4d25f0ed9bf41f72a033254a891f415316 (diff)
Generate missing message_id from byte hash
-rw-r--r--melib/src/conf/mod.rs2
-rw-r--r--melib/src/mailbox/email/mod.rs7
-rw-r--r--melib/src/mailbox/thread.rs3
-rw-r--r--ui/src/components/mail/view.rs7
-rw-r--r--ui/src/lib.rs5
5 files changed, 8 insertions, 16 deletions
diff --git a/melib/src/conf/mod.rs b/melib/src/conf/mod.rs
index 87c78ef8..9ee370e4 100644
--- a/melib/src/conf/mod.rs
+++ b/melib/src/conf/mod.rs
@@ -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)]
diff --git a/melib/src/mailbox/email/mod.rs b/melib/src/mailbox/email/mod.rs
index 5f68f9d7..2148682d 100644
--- a/melib/src/mailbox/email/mod.rs
+++ b/melib/src/mailbox/email/mod.rs
@@ -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 {
diff --git a/melib/src/mailbox/thread.rs b/melib/src/mailbox/thread.rs
index d5a01d41..c94e17f9 100644
--- a/melib/src/mailbox/thread.rs
+++ b/melib/src/mailbox/thread.rs
@@ -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
diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs
index a5644ea0..74546100 100644
--- a/ui/src/components/mail/view.rs
+++ b/ui/src/components/mail/view.rs
@@ -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,
diff --git a/ui/src/lib.rs b/ui/src/lib.rs
index ce7a332c..88016b4d 100644
--- a/ui/src/lib.rs
+++ b/ui/src/lib.rs
@@ -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);
}
}