feat: mailer: send OTp link port

This commit is contained in:
Aravinth Manivannan 2024-05-17 23:24:24 +05:30
parent ff080103c7
commit e60a78054e
Signed by: realaravinth
GPG key ID: F8F50389936984FF
3 changed files with 67 additions and 0 deletions

View file

@ -0,0 +1,48 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use mockall::predicate::*;
use mockall::*;
use super::errors::*;
#[cfg(test)]
#[allow(unused_imports)]
pub use tests::*;
#[automock]
#[async_trait::async_trait]
pub trait AccountValidationLinkOutMailerPort: Send + Sync {
async fn account_validation_link(
&self,
to: &str,
username: &str,
validation_secret: &str,
) -> OutMailerPortResult<()>;
}
pub type AccountValidationLinkOutMailerPortObj =
std::sync::Arc<dyn AccountValidationLinkOutMailerPort>;
#[cfg(test)]
pub mod tests {
use super::*;
use std::sync::Arc;
pub fn mock_account_validation_link_db_port(
times: Option<usize>,
) -> AccountValidationLinkOutMailerPortObj {
let mut m = MockAccountValidationLinkOutMailerPort::new();
if let Some(times) = times {
m.expect_account_validation_link()
.times(times)
.returning(|_, _, _| Ok(()));
} else {
m.expect_account_validation_link()
.returning(|_, _, _| Ok(()));
}
Arc::new(m)
}
}

View file

@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use derive_more::Display;
use serde::{Deserialize, Serialize};
pub type OutMailerPortResult<V> = Result<V, OutMailerPortError>;
#[derive(Debug, Display, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub enum OutMailerPortError {
InternalError,
}

View file

@ -0,0 +1,6 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
pub mod account_validation_link;
pub mod errors;