@tutao/node-mimimi 284.250428.0 → 284.250428.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tutao/node-mimimi",
|
|
3
|
-
"version": "284.250428.
|
|
3
|
+
"version": "284.250428.2",
|
|
4
4
|
"main": "./dist/binding.js",
|
|
5
5
|
"types": "./dist/binding.d.ts",
|
|
6
6
|
"napi": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@tutao/otest": "284.250428.
|
|
16
|
+
"@tutao/otest": "284.250428.2",
|
|
17
17
|
"@napi-rs/cli": "3.0.0-alpha.68",
|
|
18
18
|
"typescript": "5.3.3",
|
|
19
19
|
"zx": "8.1.5"
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"version": "napi version"
|
|
31
31
|
},
|
|
32
32
|
"optionalDependencies": {
|
|
33
|
-
"@tutao/node-mimimi-win32-x64-msvc": "284.250428.
|
|
34
|
-
"@tutao/node-mimimi-linux-x64-gnu": "284.250428.
|
|
35
|
-
"@tutao/node-mimimi-darwin-universal": "284.250428.
|
|
33
|
+
"@tutao/node-mimimi-win32-x64-msvc": "284.250428.2",
|
|
34
|
+
"@tutao/node-mimimi-linux-x64-gnu": "284.250428.2",
|
|
35
|
+
"@tutao/node-mimimi-darwin-universal": "284.250428.2"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -655,10 +655,7 @@ impl ImportableMail {
|
|
|
655
655
|
pub fn from_parsed_message(parsed_message: &mail_parser::Message) -> Self {
|
|
656
656
|
let subject = parsed_message.subject().unwrap_or_default().to_string();
|
|
657
657
|
|
|
658
|
-
let date = parsed_message
|
|
659
|
-
.date()
|
|
660
|
-
.as_ref()
|
|
661
|
-
.map(|date_time| DateTime::from_millis(date_time.to_timestamp() as u64 * 1000));
|
|
658
|
+
let date = get_importable_date_time(parsed_message);
|
|
662
659
|
|
|
663
660
|
let name_as_address_if_empty_address = |mut address: MailContact| -> MailContact {
|
|
664
661
|
if address.mail_address.is_empty() && !address.name.is_empty() {
|
|
@@ -772,6 +769,22 @@ impl ImportableMail {
|
|
|
772
769
|
}
|
|
773
770
|
}
|
|
774
771
|
|
|
772
|
+
/**
|
|
773
|
+
* convert the "Date:" header value from the parsed message to something we can import.
|
|
774
|
+
* if the value isn't valid (parser returned -1 or the value doesn't fit in an u64
|
|
775
|
+
* when converted to milliseconds), we'll use midnight, 1st of January 1970 as a default.
|
|
776
|
+
*/
|
|
777
|
+
fn get_importable_date_time(message: &mail_parser::Message) -> Option<DateTime> {
|
|
778
|
+
message
|
|
779
|
+
.date()
|
|
780
|
+
.map(mail_parser::DateTime::to_timestamp)
|
|
781
|
+
.map(|timestamp| timestamp.max(0))
|
|
782
|
+
.into_iter()
|
|
783
|
+
.filter_map(|millis| (millis as u64).checked_mul(1000))
|
|
784
|
+
.map(DateTime::from_millis)
|
|
785
|
+
.next()
|
|
786
|
+
}
|
|
787
|
+
|
|
775
788
|
#[cfg(test)]
|
|
776
789
|
mod mime_string_to_importable_mail_test;
|
|
777
790
|
#[cfg(test)]
|
package/src/importer.rs
CHANGED
|
@@ -782,6 +782,21 @@ pub mod tests {
|
|
|
782
782
|
assert_eq!(remote_state.successfulMails, 1);
|
|
783
783
|
}
|
|
784
784
|
|
|
785
|
+
#[cfg_attr(
|
|
786
|
+
not(feature = "test-with-local-http-server"),
|
|
787
|
+
ignore = "require local http server."
|
|
788
|
+
)]
|
|
789
|
+
#[tokio::test]
|
|
790
|
+
async fn can_import_single_eml_file_with_invalid_date() {
|
|
791
|
+
let importer = init_file_importer(vec!["brokendate.eml"]).await;
|
|
792
|
+
importer.start_stateful_import().await.unwrap();
|
|
793
|
+
|
|
794
|
+
let remote_state = importer.essentials.load_remote_state().await.unwrap();
|
|
795
|
+
assert_eq!(remote_state.status, ImportStatus::Finished as i64);
|
|
796
|
+
assert_eq!(remote_state.failedMails, 0);
|
|
797
|
+
assert_eq!(remote_state.successfulMails, 1);
|
|
798
|
+
}
|
|
799
|
+
|
|
785
800
|
#[test]
|
|
786
801
|
fn max_request_size_in_test_is_different() {
|
|
787
802
|
assert_eq!(1024 * 5, MAX_REQUEST_SIZE);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Content-Type: text/plain; charset=iso-8859-1; format=flowed
|
|
2
|
+
Content-Transfer-Encoding: 8bit
|
|
3
|
+
To: sorry@noemail.eu
|
|
4
|
+
From: noreply@noemail.eu
|
|
5
|
+
Date: Fri, Dec 14 2001 16:05:48 -0800
|
|
6
|
+
MIME-Version: 1.0
|
|
7
|
+
Subject: Broken date
|
|
8
|
+
|
|
9
|
+
This mail contains a date header that doesn't conform to the standard.
|