From 7efe08a9b8ef0af63cc80ab8fc67c5dabb726d26 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Thu, 30 Jun 2022 15:22:25 +0200 Subject: Implement IMAP fetch internaldate --- Cargo.lock | 38 ++++++++++++++++++++++++++++++-------- Cargo.toml | 6 ++++-- src/imap/mailbox_view.rs | 6 +++++- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a04cfe4..765809d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,6 +26,7 @@ dependencies = [ "async-trait", "base64", "boitalettres", + "chrono", "clap", "duplexify", "futures", @@ -247,6 +248,27 @@ dependencies = [ "wasm-bindgen-futures", ] +[[package]] +name = "async-stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e" +dependencies = [ + "async-stream-impl", + "futures-core", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "async-task" version = "4.2.0" @@ -403,10 +425,11 @@ dependencies = [ [[package]] name = "boitalettres" -version = "0.0.1" -source = "git+https://git.deuxfleurs.fr/KokaKiwi/boitalettres.git?branch=main#01ee8c872b15e2aecb4c0ef5c2dd3aa6cc3c4d3c" +version = "0.1.0" +source = "git+https://git.deuxfleurs.fr/quentin/boitalettres.git?branch=expose-mydatetime#874fa91186989ced7ebac270f18b64e47ee4f98a" dependencies = [ "async-compat", + "async-stream", "bytes", "futures", "imap-codec", @@ -1130,8 +1153,7 @@ dependencies = [ [[package]] name = "imap-codec" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab1edebd5f2288f8c195ae53fbb7342f5e568739b439a5923be21a9f61f3364" +source = "git+https://github.com/superboum/imap-codec.git?branch=v0.5.x#09f18cff93b7e17e5b84ab1fbf06b8d13b8e9e2d" dependencies = [ "abnf-core", "base64", @@ -1354,9 +1376,9 @@ dependencies = [ [[package]] name = "miette" -version = "4.7.1" +version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c90329e44f9208b55f45711f9558cec15d7ef8295cc65ecd6d4188ae8edc58c" +checksum = "6ec753a43fd71bb5f28751c9ec17fbe89d6d26ca8282d1e1f82f5ac3dbd5581e" dependencies = [ "miette-derive", "once_cell", @@ -1366,9 +1388,9 @@ dependencies = [ [[package]] name = "miette-derive" -version = "4.7.1" +version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b5bc45b761bcf1b5e6e6c4128cd93b84c218721a8d9b894aa0aff4ed180174c" +checksum = "fdfc33ea15c5446600f91d319299dd40301614afff7143cdfa9bf4c09da3ca64" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index cad5bef..ac3e641 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,10 +39,12 @@ zstd = { version = "0.9", default-features = false } tracing-subscriber = "0.3" tracing = "0.1" tower = "0.4" -imap-codec = "0.5" + +imap-codec = { git = "https://github.com/superboum/imap-codec.git", branch = "v0.5.x" } +chrono = { version = "0.4", default-features = false, features = ["alloc"] } k2v-client = { git = "https://git.deuxfleurs.fr/Deuxfleurs/garage.git", branch = "main" } -boitalettres = { git = "https://git.deuxfleurs.fr/KokaKiwi/boitalettres.git", branch = "main" } +boitalettres = { git = "https://git.deuxfleurs.fr/quentin/boitalettres.git", branch = "expose-mydatetime" } smtp-message = { git = "http://github.com/Alexis211/kannader", branch = "feature/lmtp" } smtp-server = { git = "http://github.com/Alexis211/kannader", branch = "feature/lmtp" } diff --git a/src/imap/mailbox_view.rs b/src/imap/mailbox_view.rs index 0feb588..7707aaf 100644 --- a/src/imap/mailbox_view.rs +++ b/src/imap/mailbox_view.rs @@ -4,8 +4,10 @@ use std::sync::Arc; use anyhow::{anyhow, bail, Error, Result}; use boitalettres::proto::res::body::Data as Body; +use chrono::{Offset, Utc, TimeZone}; use futures::stream::{FuturesOrdered, StreamExt}; use imap_codec::types::address::Address; +use imap_codec::types::datetime::MyDateTime; use imap_codec::types::core::{Atom, IString, NString, NonZeroBytes}; use imap_codec::types::envelope::Envelope; use imap_codec::types::fetch_attributes::{FetchAttribute, MacroOrFetchAttributes}; @@ -288,7 +290,9 @@ impl MailboxView { todo!() } FetchAttribute::InternalDate => { - todo!() + attributes.push(MessageAttribute::InternalDate( + MyDateTime(Utc.fix().timestamp(i64::try_from(meta.internaldate / 1000)?, 0)) + )); } } } -- cgit v1.2.3