Kaynağa Gözat

Update mail_parser version on cargo.toml

A lot has changed  on the mail_parser library listed on the library
dependencies file (Cargo.toml) and it created many issues on Crabmail.

Main modifications because of changes on the mail_parser library API:
get_x() -> x()
to_iso8601() -> to_rfc3339()

Signed-off-by: Reda <reda@42d.io>
Reda Sallahi 5 ay önce
ebeveyn
işleme
5f08a88065
6 değiştirilmiş dosya ile 24 ekleme ve 24 silme
  1. 1 1
      Cargo.toml
  2. 14 14
      src/models.rs
  3. 1 1
      src/templates/gmi.rs
  4. 1 1
      src/templates/html.rs
  5. 3 3
      src/templates/xml.rs
  6. 4 4
      src/threading.rs

+ 1 - 1
Cargo.toml

@@ -12,6 +12,6 @@ anyhow = "1.0.52"
 linkify = "0.8.0" 
 # using my fork just to upstream patches faster.
 mail-builder = {git = "https://github.com/alexwennerberg/mail-builder"}
-mail-parser = {git = "https://github.com/stalwartlabs/mail-parser", default-features=false}
+mail-parser = { git = "https://github.com/stalwartlabs/mail-parser", default-features=false, tag = "0.8.2" }
 once_cell = "1.9.0"
 urlencoding = "2.1.0"

+ 14 - 14
src/models.rs

@@ -209,27 +209,27 @@ impl StrMessage {
     }
 
     pub fn new(msg: &Message) -> StrMessage {
-        let id = msg.get_message_id().unwrap_or("");
+        let id = msg.message_id().unwrap_or("");
         // TODO duplicate in threading.rs
         let received = msg
-            .get_received()
+            .received()
             .as_datetime_ref()
-            .or_else(|| msg.get_date())
+            .or_else(|| msg.date())
             .unwrap()
             .clone();
-        let subject = msg.get_subject().unwrap_or("(No Subject)");
-        let thread_subject = msg.get_thread_name().unwrap_or("(No Subject)");
+        let subject = msg.subject().unwrap_or("(No Subject)");
+        let thread_subject = msg.thread_name().unwrap_or("(No Subject)");
         let invalid_email = Addr::new(None, "invalid-email");
-        let preview = match msg.get_body_preview(80) {
+        let preview = match msg.body_preview(80) {
             Some(b) => b.to_string(),
             None => String::new(),
         };
-        let from = match msg.get_from() {
+        let from = match msg.from() {
             HeaderValue::Address(fr) => fr,
             _ => &invalid_email,
         };
         let from = MailAddress::from_addr(from);
-        let date = msg.get_date().cloned().unwrap_or(crate::util::EPOCH);
+        let date = msg.date().cloned().unwrap_or(crate::util::EPOCH);
 
         /// Turns a header value into a list of addresses
         fn addr_list(header: &HeaderValue) -> Vec<MailAddress> {
@@ -242,21 +242,21 @@ impl StrMessage {
             }
         }
 
-        let to = addr_list(msg.get_to());
-        let cc = addr_list(msg.get_cc());
+        let to = addr_list(msg.to());
+        let cc = addr_list(msg.cc());
 
-        let in_reply_to = msg.get_in_reply_to().as_text_ref().map(|a| a.to_string());
+        let in_reply_to = msg.in_reply_to().as_text_ref().map(|a| a.to_string());
 
         // TODO linkify body
         // TODO unformat-flowed
         let body = msg
-            .get_text_body(0)
+            .body_text(0)
             .unwrap_or(Cow::Borrowed("[No message body]"));
 
         // life is a nightmare
         let flowed = msg
-            .get_text_part(0)
-            .and_then(|x| x.headers_rfc.get(&RfcHeader::ContentType))
+            .text_part(0)
+            .and_then(|x| x.headers.get(&RfcHeader::ContentType))
             .and_then(|x| x.as_content_type_ref())
             .and_then(|x| x.attributes.as_ref())
             .and_then(|x| x.get("format"))

+ 1 - 1
src/templates/gmi.rs

@@ -50,7 +50,7 @@ impl List {
                         replies = thread.reply_count,
                         preview = h(&thread.message.preview),
                         // get only year-month-day part of datetime
-                        date = thread.last_reply.to_iso8601().split_once('T').unwrap().0,
+                        date = thread.last_reply.to_rfc3339().split_once('T').unwrap().0,
                         from = h(thread
                             .message
                             .from

+ 1 - 1
src/templates/html.rs

@@ -92,7 +92,7 @@ impl List {
                         subject = x(&thread.message.subject),
                         replies = thread.reply_count,
                         // get only year-month-day part of datetime
-                        date = thread.last_reply.to_iso8601().split_once('T').unwrap().0,
+                        date = thread.last_reply.to_rfc3339().split_once('T').unwrap().0,
                         from = x(thread
                             .message
                             .from

+ 3 - 3
src/templates/xml.rs

@@ -66,7 +66,7 @@ impl StrMessage {
             &x(&msg.subject),
             &x(&self.url),
             &x(&msg.id),
-            &msg.received.to_iso8601(),
+            &msg.received.to_rfc3339(),
             &x(&msg.from.clone().name.unwrap_or(msg.from.clone().address)),
             &x(&msg.from.address),
             &x(&body),
@@ -90,7 +90,7 @@ impl List {
         feed(
             &self.config.name,
             &self.url,
-            &last_updated.to_iso8601(),
+            &last_updated.to_rfc3339(),
             &self.config.email,
             &self.config.email,
             &entry_list,
@@ -109,7 +109,7 @@ impl Thread {
         feed(
             &root.subject,
             &self.url,
-            &root.received.to_iso8601(),
+            &root.received.to_rfc3339(),
             root.from.name.as_ref().unwrap_or(&root.from.address),
             &root.from.address,
             &entry_list,

+ 4 - 4
src/threading.rs

@@ -35,14 +35,14 @@ impl ThreadIdx {
     // Todo enumerate errors or something
     // TODO should be format agnostic (use internal representation of email)
     pub fn add_email(&mut self, msg: &Message, path: PathBuf) {
-        let msg_id = match msg.get_message_id() {
+        let msg_id = match msg.message_id() {
             Some(m) => m,
             None => return,
         };
         let time = match msg
-            .get_received()
+            .received()
             .as_datetime_ref()
-            .or_else(|| msg.get_date())
+            .or_else(|| msg.date())
         {
             Some(t) => t.clone(),
             None => return,
@@ -51,7 +51,7 @@ impl ThreadIdx {
             // TODO handle duplicate msg case. Don't allow overwrites
             return;
         }
-        let thread_name = thread_name(msg.get_subject().unwrap_or("(No Subject)"));
+        let thread_name = thread_name(msg.subject().unwrap_or("(No Subject)"));
 
         let msg = Msg {
             id: msg_id.to_owned(),