mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 02:57:02 +08:00
feat(email): integrate email service using AWS SES (#1158)
This commit is contained in:
@ -7,6 +7,8 @@ use std::{
|
||||
use api_models::enums;
|
||||
use common_utils::ext_traits::ConfigExt;
|
||||
use config::{Environment, File};
|
||||
#[cfg(feature = "email")]
|
||||
use external_services::email::EmailSettings;
|
||||
#[cfg(feature = "kms")]
|
||||
use external_services::kms;
|
||||
use redis_interface::RedisSettings;
|
||||
@ -69,6 +71,8 @@ pub struct Settings {
|
||||
pub connector_customer: ConnectorCustomer,
|
||||
#[cfg(feature = "dummy_connector")]
|
||||
pub dummy_connector: DummyConnector,
|
||||
#[cfg(feature = "email")]
|
||||
pub email: EmailSettings,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone, Default)]
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
use actix_web::{web, Scope};
|
||||
#[cfg(feature = "email")]
|
||||
use external_services::email::{AwsSes, EmailClient};
|
||||
use tokio::sync::oneshot;
|
||||
|
||||
#[cfg(feature = "dummy_connector")]
|
||||
@ -22,12 +24,16 @@ pub struct AppState {
|
||||
pub flow_name: String,
|
||||
pub store: Box<dyn StorageInterface>,
|
||||
pub conf: Settings,
|
||||
#[cfg(feature = "email")]
|
||||
pub email_client: Box<dyn EmailClient>,
|
||||
}
|
||||
|
||||
pub trait AppStateInfo {
|
||||
fn conf(&self) -> Settings;
|
||||
fn flow_name(&self) -> String;
|
||||
fn store(&self) -> Box<dyn StorageInterface>;
|
||||
#[cfg(feature = "email")]
|
||||
fn email_client(&self) -> Box<dyn EmailClient>;
|
||||
}
|
||||
|
||||
impl AppStateInfo for AppState {
|
||||
@ -40,6 +46,10 @@ impl AppStateInfo for AppState {
|
||||
fn store(&self) -> Box<dyn StorageInterface> {
|
||||
self.store.to_owned()
|
||||
}
|
||||
#[cfg(feature = "email")]
|
||||
fn email_client(&self) -> Box<dyn EmailClient> {
|
||||
self.email_client.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
@ -56,10 +66,15 @@ impl AppState {
|
||||
StorageImpl::Mock => Box::new(MockDb::new(&conf).await),
|
||||
};
|
||||
|
||||
#[cfg(feature = "email")]
|
||||
#[allow(clippy::expect_used)]
|
||||
let email_client = Box::new(AwsSes::new(&conf.email).await);
|
||||
Self {
|
||||
flow_name: String::from("default"),
|
||||
store,
|
||||
conf,
|
||||
#[cfg(feature = "email")]
|
||||
email_client,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user