aboutsummaryrefslogtreecommitdiff
path: root/src/lmtp.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-30 17:40:59 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-30 17:40:59 +0200
commit2c61af6684c44e3558cc808c6b319bc9706adb00 (patch)
treed8828a6faed5c42665ed9a1732cb284ff045a3b7 /src/lmtp.rs
parent484ad97b65ba2295aadd9cf7eaf865573b859a10 (diff)
downloadaerogramme-2c61af6684c44e3558cc808c6b319bc9706adb00.tar.gz
aerogramme-2c61af6684c44e3558cc808c6b319bc9706adb00.zip
More work on incoming mails, but no mails yet
Diffstat (limited to 'src/lmtp.rs')
-rw-r--r--src/lmtp.rs39
1 files changed, 1 insertions, 38 deletions
diff --git a/src/lmtp.rs b/src/lmtp.rs
index 5ab7429..78fe28d 100644
--- a/src/lmtp.rs
+++ b/src/lmtp.rs
@@ -21,6 +21,7 @@ use crate::config::*;
use crate::cryptoblob::*;
use crate::login::*;
use crate::mail::unique_ident::*;
+use crate::mail::incoming::EncryptedMessage;
pub struct LmtpServer {
bind_addr: SocketAddr,
@@ -210,41 +211,3 @@ impl Config for LmtpServer {
}
}
-// ----
-
-struct EncryptedMessage {
- key: Key,
- encrypted_body: Vec<u8>,
-}
-
-impl EncryptedMessage {
- fn new(body: Vec<u8>) -> Result<Self> {
- let key = gen_key();
- let encrypted_body = seal(&body, &key)?;
- Ok(Self {
- key,
- encrypted_body,
- })
- }
-
- async fn deliver_to(self: Arc<Self>, creds: PublicCredentials) -> Result<()> {
- let s3_client = creds.storage.s3_client()?;
-
- let encrypted_key =
- sodiumoxide::crypto::sealedbox::seal(self.key.as_ref(), &creds.public_key);
- let key_header = base64::encode(&encrypted_key);
-
- let mut por = PutObjectRequest::default();
- por.bucket = creds.storage.bucket.clone();
- por.key = format!("incoming/{}", gen_ident().to_string());
- por.metadata = Some(
- [("Message-Key".to_string(), key_header)]
- .into_iter()
- .collect::<HashMap<_, _>>(),
- );
- por.body = Some(self.encrypted_body.clone().into());
- s3_client.put_object(por).await?;
-
- Ok(())
- }
-}