feat: mailer: send OTp link port
This commit is contained in:
parent
ff080103c7
commit
e60a78054e
3 changed files with 67 additions and 0 deletions
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
13
src/identity/application/port/output/mailer/errors.rs
Normal file
13
src/identity/application/port/output/mailer/errors.rs
Normal 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,
|
||||||
|
}
|
6
src/identity/application/port/output/mailer/mod.rs
Normal file
6
src/identity/application/port/output/mailer/mod.rs
Normal 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;
|
Loading…
Reference in a new issue