diff --git a/imessage-database/src/message_types/handwriting.rs b/imessage-database/src/message_types/handwriting.rs index 84508c8d..f4431b94 100644 --- a/imessage-database/src/message_types/handwriting.rs +++ b/imessage-database/src/message_types/handwriting.rs @@ -10,3 +10,9 @@ impl HandwrittenMessage { Self {} } } + +impl Default for HandwrittenMessage { + fn default() -> Self { + Self::new() + } +} diff --git a/imessage-exporter/src/app/export_type.rs b/imessage-exporter/src/app/export_type.rs index b0fd962d..c27ab852 100644 --- a/imessage-exporter/src/app/export_type.rs +++ b/imessage-exporter/src/app/export_type.rs @@ -8,17 +8,17 @@ use std::fmt::Display; #[derive(PartialEq, Eq, Debug)] pub enum ExportType { /// HTML file export - HTML, + Html, /// Text file export - TXT, + Txt, } impl ExportType { /// Given user's input, return a variant if the input matches one pub fn from_cli(platform: &str) -> Option { match platform.to_lowercase().as_str() { - "txt" => Some(Self::TXT), - "html" => Some(Self::HTML), + "txt" => Some(Self::Txt), + "html" => Some(Self::Html), _ => None, } } @@ -27,8 +27,8 @@ impl ExportType { impl Display for ExportType { fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - ExportType::TXT => write!(fmt, "txt"), - ExportType::HTML => write!(fmt, "html"), + ExportType::Txt => write!(fmt, "txt"), + ExportType::Html => write!(fmt, "html"), } } } @@ -41,23 +41,23 @@ mod tests { fn can_parse_html_any_case() { assert!(matches!( ExportType::from_cli("html"), - Some(ExportType::HTML) + Some(ExportType::Html) )); assert!(matches!( ExportType::from_cli("HTML"), - Some(ExportType::HTML) + Some(ExportType::Html) )); assert!(matches!( ExportType::from_cli("HtMl"), - Some(ExportType::HTML) + Some(ExportType::Html) )); } #[test] fn can_parse_txt_any_case() { - assert!(matches!(ExportType::from_cli("txt"), Some(ExportType::TXT))); - assert!(matches!(ExportType::from_cli("TXT"), Some(ExportType::TXT))); - assert!(matches!(ExportType::from_cli("tXt"), Some(ExportType::TXT))); + assert!(matches!(ExportType::from_cli("txt"), Some(ExportType::Txt))); + assert!(matches!(ExportType::from_cli("TXT"), Some(ExportType::Txt))); + assert!(matches!(ExportType::from_cli("tXt"), Some(ExportType::Txt))); } #[test] diff --git a/imessage-exporter/src/app/options.rs b/imessage-exporter/src/app/options.rs index 68a1428c..a1f57a4a 100644 --- a/imessage-exporter/src/app/options.rs +++ b/imessage-exporter/src/app/options.rs @@ -509,7 +509,7 @@ mod arg_tests { attachment_root: None, attachment_manager: AttachmentManager::default(), diagnostic: false, - export_type: Some(ExportType::HTML), + export_type: Some(ExportType::Html), export_path: validate_path(Some(&tmp_dir), &None).unwrap(), query_context: QueryContext::default(), no_lazy: false, @@ -537,7 +537,7 @@ mod arg_tests { attachment_root: None, attachment_manager: AttachmentManager::default(), diagnostic: false, - export_type: Some(ExportType::TXT), + export_type: Some(ExportType::Txt), export_path: validate_path(None, &None).unwrap(), query_context: QueryContext::default(), no_lazy: true, @@ -657,7 +657,7 @@ mod path_tests { fn can_validate_empty() { let tmp = String::from("/tmp"); let export_path = Some(&tmp); - let export_type = Some(ExportType::TXT); + let export_type = Some(ExportType::Txt); let result = validate_path(export_path, &export_type.as_ref()); @@ -668,7 +668,7 @@ mod path_tests { fn can_validate_different_type() { let tmp = String::from("/tmp"); let export_path = Some(&tmp); - let export_type = Some(ExportType::TXT); + let export_type = Some(ExportType::Txt); let result = validate_path(export_path, &export_type.as_ref()); @@ -685,7 +685,7 @@ mod path_tests { fn can_validate_same_type() { let tmp = String::from("/tmp"); let export_path = Some(&tmp); - let export_type = Some(ExportType::TXT); + let export_type = Some(ExportType::Txt); let result = validate_path(export_path, &export_type.as_ref()); diff --git a/imessage-exporter/src/app/runtime.rs b/imessage-exporter/src/app/runtime.rs index d214e67d..96b0e5b0 100644 --- a/imessage-exporter/src/app/runtime.rs +++ b/imessage-exporter/src/app/runtime.rs @@ -325,10 +325,10 @@ impl Config { // Create exporter, pass it data we care about, then kick it off match export_type { - ExportType::HTML => { + ExportType::Html => { HTML::new(self).iter_messages()?; } - ExportType::TXT => { + ExportType::Txt => { TXT::new(self).iter_messages()?; } } diff --git a/imessage-exporter/src/app/sanitizers.rs b/imessage-exporter/src/app/sanitizers.rs index 2b4cf04d..82500111 100644 --- a/imessage-exporter/src/app/sanitizers.rs +++ b/imessage-exporter/src/app/sanitizers.rs @@ -60,8 +60,6 @@ mod test_filename { #[cfg(test)] mod tests { - use std::borrow::Cow; - use crate::app::sanitizers::sanitize_html; #[test] diff --git a/imessage-exporter/src/exporters/html.rs b/imessage-exporter/src/exporters/html.rs index 07cbdee8..06e63753 100644 --- a/imessage-exporter/src/exporters/html.rs +++ b/imessage-exporter/src/exporters/html.rs @@ -298,25 +298,28 @@ impl<'a> Writer<'a> for HTML<'a> { "
", "
", ); - continue; } match message_part { BubbleType::Text(text) => { - if text.starts_with(FITNESS_RECEIVER) { - self.add_line( - &mut formatted_message, - &text.replace(FITNESS_RECEIVER, YOU), - "", - "", - ); - } else { - self.add_line( - &mut formatted_message, - &sanitize_html(text), - "", - "", - ); + // Render the message body if the message was not edited + // If it was edited, it was rendered already + if !message.is_edited() { + if text.starts_with(FITNESS_RECEIVER) { + self.add_line( + &mut formatted_message, + &text.replace(FITNESS_RECEIVER, YOU), + "", + "", + ); + } else { + self.add_line( + &mut formatted_message, + &sanitize_html(text), + "", + "", + ); + } } } BubbleType::Attachment => {