aboutsummaryrefslogtreecommitdiff
path: root/src/mail
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-29 20:00:38 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-29 20:00:38 +0200
commitb71d9678892814a62d422af11eb91e61943836a2 (patch)
treebbfcb8964fa87361595dfb89d9c174bf24458b0a /src/mail
parentde71f4b4edcd66e68a79ce15800a7eab0f6ad72c (diff)
downloadaerogramme-b71d9678892814a62d422af11eb91e61943836a2.tar.gz
aerogramme-b71d9678892814a62d422af11eb91e61943836a2.zip
Fetch ENVELOPE works \o/
Diffstat (limited to 'src/mail')
-rw-r--r--src/mail/mailbox.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/mail/mailbox.rs b/src/mail/mailbox.rs
index f559d5c..bb1ca7a 100644
--- a/src/mail/mailbox.rs
+++ b/src/mail/mailbox.rs
@@ -1,9 +1,7 @@
use anyhow::{anyhow, bail, Result};
use k2v_client::K2vClient;
use k2v_client::{BatchReadOp, Filter, K2vValue};
-use rusoto_s3::{
- DeleteObjectRequest, GetObjectRequest, PutObjectRequest, S3Client, S3,
-};
+use rusoto_s3::{DeleteObjectRequest, GetObjectRequest, PutObjectRequest, S3Client, S3};
use serde::{Deserialize, Serialize};
use tokio::io::AsyncReadExt;
use tokio::sync::RwLock;
@@ -44,7 +42,7 @@ impl Mailbox {
/// Sync data with backing store
pub async fn sync(&self) -> Result<()> {
- self.mbox.write().await.uid_index.sync().await
+ self.mbox.write().await.sync().await
}
/// Get a clone of the current UID Index of this mailbox
@@ -60,7 +58,13 @@ impl Mailbox {
/// Copy an email from an other Mailbox to this mailbox
/// (use this when possible, as it allows for a certain number of storage optimizations)
- pub async fn copy(&self, _from: &Mailbox, _uid: ImapUid) -> Result<()> {
+ pub async fn copy_from(&self, _from: &Mailbox, _uuid: UniqueIdent) -> Result<()> {
+ unimplemented!()
+ }
+
+ /// Move an email from an other Mailbox to this mailbox
+ /// (use this when possible, as it allows for a certain number of storage optimizations)
+ pub async fn move_from(&self, _from: &Mailbox, _uuid: UniqueIdent) -> Result<()> {
unimplemented!()
}
@@ -98,6 +102,11 @@ struct MailboxInternal {
}
impl MailboxInternal {
+ async fn sync(&mut self) -> Result<()> {
+ self.uid_index.sync().await?;
+ Ok(())
+ }
+
async fn fetch_meta(&self, ids: &[UniqueIdent]) -> Result<Vec<MailMeta>> {
let ids = ids.iter().map(|x| x.to_string()).collect::<Vec<_>>();
let ops = ids