cleanup
This commit is contained in:
parent
c7f767b7d2
commit
4bc3f70e28
3 changed files with 30 additions and 31 deletions
|
@ -9,14 +9,14 @@ pub struct LdapLoginProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LdapLoginProvider {
|
impl LdapLoginProvider {
|
||||||
pub fn new(config: LoginLdapConfig) -> Result<Self> {
|
pub fn new(_config: LoginLdapConfig) -> Result<Self> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl LoginProvider for LdapLoginProvider {
|
impl LoginProvider for LdapLoginProvider {
|
||||||
async fn login(&self, username: &str, password: &str) -> Result<Credentials> {
|
async fn login(&self, _username: &str, _password: &str) -> Result<Credentials> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
use anyhow::{anyhow, bail, Result};
|
use anyhow::Result;
|
||||||
use k2v_client::{BatchDeleteOp, BatchReadOp, Filter, K2vClient, K2vValue};
|
use k2v_client::K2vClient;
|
||||||
use rusoto_core::HttpClient;
|
|
||||||
use rusoto_credential::{AwsCredentials, StaticProvider, ProvideAwsCredentials};
|
|
||||||
use rusoto_s3::{
|
|
||||||
DeleteObjectRequest, GetObjectRequest, ListObjectsV2Request, PutObjectRequest, S3Client, S3,
|
|
||||||
};
|
|
||||||
use rusoto_signature::Region;
|
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
|
use rusoto_core::HttpClient;
|
||||||
|
use rusoto_credential::{ProvideAwsCredentials, StaticProvider};
|
||||||
|
use rusoto_s3::S3Client;
|
||||||
|
use rusoto_signature::Region;
|
||||||
|
|
||||||
use crate::cryptoblob::Key;
|
|
||||||
use crate::bayou::Bayou;
|
use crate::bayou::Bayou;
|
||||||
|
use crate::cryptoblob::Key;
|
||||||
use crate::login::Credentials;
|
use crate::login::Credentials;
|
||||||
use crate::uidindex::*;
|
use crate::uidindex::*;
|
||||||
|
|
||||||
|
@ -25,11 +23,14 @@ pub struct Mailbox {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Mailbox {
|
impl Mailbox {
|
||||||
pub async fn new(k2v_region: Region, s3_region: Region, creds: Credentials,name: String) -> Result<Self> {
|
pub async fn new(
|
||||||
let aws_creds_provider = StaticProvider::new_minimal(
|
k2v_region: Region,
|
||||||
creds.aws_access_key_id,
|
s3_region: Region,
|
||||||
creds.aws_secret_access_key,
|
creds: Credentials,
|
||||||
);
|
name: String,
|
||||||
|
) -> Result<Self> {
|
||||||
|
let aws_creds_provider =
|
||||||
|
StaticProvider::new_minimal(creds.aws_access_key_id, creds.aws_secret_access_key);
|
||||||
let aws_creds = aws_creds_provider.credentials().await?;
|
let aws_creds = aws_creds_provider.credentials().await?;
|
||||||
|
|
||||||
let uid_index = Bayou::<UidIndex>::new(
|
let uid_index = Bayou::<UidIndex>::new(
|
||||||
|
@ -40,7 +41,7 @@ impl Mailbox {
|
||||||
name.clone(),
|
name.clone(),
|
||||||
creds.master_key.clone(),
|
creds.master_key.clone(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let k2v_client = K2vClient::new(k2v_region, creds.bucket.clone(), aws_creds, None)?;
|
let k2v_client = K2vClient::new(k2v_region, creds.bucket.clone(), aws_creds, None)?;
|
||||||
let s3_client = S3Client::new_with(HttpClient::new()?, aws_creds_provider, s3_region);
|
let s3_client = S3Client::new_with(HttpClient::new()?, aws_creds_provider, s3_region);
|
||||||
|
|
||||||
|
@ -54,16 +55,15 @@ impl Mailbox {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub async fn test(&mut self) -> Result<()> {
|
pub async fn test(&mut self) -> Result<()> {
|
||||||
|
|
||||||
self.uid_index.sync().await?;
|
self.uid_index.sync().await?;
|
||||||
|
|
||||||
dump(&self.uid_index);
|
dump(&self.uid_index);
|
||||||
|
|
||||||
let mut rand_id = [0u8; 24];
|
let mut rand_id = [0u8; 24];
|
||||||
rand_id[..16].copy_from_slice(&u128::to_be_bytes(thread_rng().gen()));
|
rand_id[..16].copy_from_slice(&u128::to_be_bytes(thread_rng().gen()));
|
||||||
let add_mail_op = self.uid_index
|
let add_mail_op = self
|
||||||
|
.uid_index
|
||||||
.state()
|
.state()
|
||||||
.op_mail_add(MailUuid(rand_id), vec!["\\Unseen".into()]);
|
.op_mail_add(MailUuid(rand_id), vec!["\\Unseen".into()]);
|
||||||
self.uid_index.push(add_mail_op).await?;
|
self.uid_index.push(add_mail_op).await?;
|
||||||
|
@ -72,7 +72,8 @@ impl Mailbox {
|
||||||
|
|
||||||
if self.uid_index.state().mails_by_uid.len() > 6 {
|
if self.uid_index.state().mails_by_uid.len() > 6 {
|
||||||
for i in 0..2 {
|
for i in 0..2 {
|
||||||
let (_, uuid) = self.uid_index
|
let (_, uuid) = self
|
||||||
|
.uid_index
|
||||||
.state()
|
.state()
|
||||||
.mails_by_uid
|
.mails_by_uid
|
||||||
.iter()
|
.iter()
|
||||||
|
|
18
src/main.rs
18
src/main.rs
|
@ -2,22 +2,17 @@ mod bayou;
|
||||||
mod config;
|
mod config;
|
||||||
mod cryptoblob;
|
mod cryptoblob;
|
||||||
mod login;
|
mod login;
|
||||||
|
mod mailbox;
|
||||||
mod time;
|
mod time;
|
||||||
mod uidindex;
|
mod uidindex;
|
||||||
mod mailbox;
|
|
||||||
|
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use rand::prelude::*;
|
|
||||||
use rusoto_credential::{EnvironmentProvider, ProvideAwsCredentials};
|
|
||||||
use rusoto_signature::Region;
|
use rusoto_signature::Region;
|
||||||
|
|
||||||
use bayou::*;
|
|
||||||
use config::*;
|
use config::*;
|
||||||
use cryptoblob::Key;
|
|
||||||
use login::{ldap_provider::*, static_provider::*, *};
|
use login::{ldap_provider::*, static_provider::*, *};
|
||||||
use uidindex::*;
|
|
||||||
use mailbox::Mailbox;
|
use mailbox::Mailbox;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
@ -68,10 +63,13 @@ impl Main {
|
||||||
async fn run(self: &Arc<Self>) -> Result<()> {
|
async fn run(self: &Arc<Self>) -> Result<()> {
|
||||||
let creds = self.login_provider.login("lx", "plop").await?;
|
let creds = self.login_provider.login("lx", "plop").await?;
|
||||||
|
|
||||||
let mut mailbox = Mailbox::new(self.k2v_region.clone(),
|
let mut mailbox = Mailbox::new(
|
||||||
self.s3_region.clone(),
|
self.k2v_region.clone(),
|
||||||
creds.clone(),
|
self.s3_region.clone(),
|
||||||
"TestMailbox".to_string()).await?;
|
creds.clone(),
|
||||||
|
"TestMailbox".to_string(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
mailbox.test().await?;
|
mailbox.test().await?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue