mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
refactor(email): Add recipient emails in email config (#5964)
This commit is contained in:
@ -375,10 +375,12 @@ wildcard_origin = false # If true, allows any origin to make req
|
||||
|
||||
# EmailClient configuration. Only applicable when the `email` feature flag is enabled.
|
||||
[email]
|
||||
sender_email = "example@example.com" # Sender email
|
||||
aws_region = "" # AWS region used by AWS SES
|
||||
allowed_unverified_days = 1 # Number of days the api calls ( with jwt token ) can be made without verifying the email
|
||||
active_email_client = "SES" # The currently active email client
|
||||
sender_email = "example@example.com" # Sender email
|
||||
aws_region = "" # AWS region used by AWS SES
|
||||
allowed_unverified_days = 1 # Number of days the api calls ( with jwt token ) can be made without verifying the email
|
||||
active_email_client = "SES" # The currently active email client
|
||||
recon_recipient_email = "recon@example.com" # Recipient email for recon request email
|
||||
prod_intent_recipient_email = "business@example.com" # Recipient email for prod intent email
|
||||
|
||||
# Configuration for aws ses, applicable when the active email client is SES
|
||||
[email.aws_ses]
|
||||
|
||||
@ -60,6 +60,8 @@ sender_email = "example@example.com" # Sender email
|
||||
aws_region = "" # AWS region used by AWS SES
|
||||
allowed_unverified_days = 1 # Number of days the api calls ( with jwt token ) can be made without verifying the email
|
||||
active_email_client = "SES" # The currently active email client
|
||||
recon_recipient_email = "recon@example.com" # Recipient email for recon request email
|
||||
prod_intent_recipient_email = "business@example.com" # Recipient email for prod intent email
|
||||
|
||||
# Configuration for aws ses, applicable when the active email client is SES
|
||||
[email.aws_ses]
|
||||
@ -300,9 +302,6 @@ public = { name = "hyperswitch", base_url = "http://localhost:8080", schema = "p
|
||||
[user_auth_methods]
|
||||
encryption_key = "user_auth_table_encryption_key" # Encryption key used for encrypting data in user_authentication_methods table
|
||||
|
||||
[recipient_emails]
|
||||
recon = "recon@example.com"
|
||||
|
||||
[network_tokenization_service] # Network Tokenization Service Configuration
|
||||
generate_token_url= "" # base url to generate token
|
||||
fetch_token_url= "" # base url to fetch token
|
||||
|
||||
@ -301,6 +301,8 @@ sender_email = "example@example.com"
|
||||
aws_region = ""
|
||||
allowed_unverified_days = 1
|
||||
active_email_client = "SES"
|
||||
recon_recipient_email = "recon@example.com"
|
||||
prod_intent_recipient_email = "business@example.com"
|
||||
|
||||
[email.aws_ses]
|
||||
email_role_arn = ""
|
||||
@ -732,9 +734,6 @@ encryption_key = "A8EF32E029BC3342E54BF2E172A4D7AA43E8EF9D2C3A624A9F04E2EF79DC69
|
||||
[locker_based_open_banking_connectors]
|
||||
connector_list = ""
|
||||
|
||||
[recipient_emails]
|
||||
recon = "recon@example.com"
|
||||
|
||||
[network_tokenization_supported_card_networks]
|
||||
card_networks = "Visa, AmericanExpress, Mastercard"
|
||||
|
||||
|
||||
@ -591,11 +591,22 @@ ach = { country = "US", currency = "USD" }
|
||||
[locker_based_open_banking_connectors]
|
||||
connector_list = ""
|
||||
|
||||
[recipient_emails]
|
||||
recon = "recon@example.com"
|
||||
|
||||
[network_tokenization_supported_card_networks]
|
||||
card_networks = "Visa, AmericanExpress, Mastercard"
|
||||
|
||||
[network_tokenization_supported_connectors]
|
||||
connector_list = "cybersource"
|
||||
|
||||
# EmailClient configuration. Only applicable when the `email` feature flag is enabled.
|
||||
[email]
|
||||
sender_email = "example@example.com" # Sender email
|
||||
aws_region = "" # AWS region used by AWS SES
|
||||
allowed_unverified_days = 1 # Number of days the api calls ( with jwt token ) can be made without verifying the email
|
||||
active_email_client = "SES" # The currently active email client
|
||||
recon_recipient_email = "recon@example.com" # Recipient email for recon request email
|
||||
prod_intent_recipient_email = "business@example.com" # Recipient email for prod intent email
|
||||
|
||||
# Configuration for aws ses, applicable when the active email client is SES
|
||||
[email.aws_ses]
|
||||
email_role_arn = "" # The amazon resource name ( arn ) of the role which has permission to send emails
|
||||
sts_role_session_name = "" # An identifier for the assumed role session, used to uniquely identify a session.
|
||||
|
||||
@ -137,6 +137,12 @@ pub struct EmailSettings {
|
||||
|
||||
/// The active email client to use
|
||||
pub active_email_client: AvailableEmailClients,
|
||||
|
||||
/// Recipient email for recon emails
|
||||
pub recon_recipient_email: pii::Email,
|
||||
|
||||
/// Recipient email for recon emails
|
||||
pub prod_intent_recipient_email: pii::Email,
|
||||
}
|
||||
|
||||
/// Errors that could occur from EmailClient.
|
||||
|
||||
@ -498,7 +498,6 @@ pub(crate) async fn fetch_raw_secrets(
|
||||
decision: conf.decision,
|
||||
locker_based_open_banking_connectors: conf.locker_based_open_banking_connectors,
|
||||
grpc_client: conf.grpc_client,
|
||||
recipient_emails: conf.recipient_emails,
|
||||
network_tokenization_supported_card_networks: conf
|
||||
.network_tokenization_supported_card_networks,
|
||||
network_tokenization_service,
|
||||
|
||||
@ -6,7 +6,7 @@ use std::{
|
||||
#[cfg(feature = "olap")]
|
||||
use analytics::{opensearch::OpenSearchConfig, ReportConfig};
|
||||
use api_models::{enums, payment_methods::RequiredFieldInfo};
|
||||
use common_utils::{ext_traits::ConfigExt, pii::Email};
|
||||
use common_utils::ext_traits::ConfigExt;
|
||||
use config::{Environment, File};
|
||||
use error_stack::ResultExt;
|
||||
#[cfg(feature = "email")]
|
||||
@ -122,7 +122,6 @@ pub struct Settings<S: SecretState> {
|
||||
pub decision: Option<DecisionConfig>,
|
||||
pub locker_based_open_banking_connectors: LockerBasedRecipientConnectorList,
|
||||
pub grpc_client: GrpcClientSettings,
|
||||
pub recipient_emails: RecipientMails,
|
||||
pub network_tokenization_supported_card_networks: NetworkTokenizationSupportedCardNetworks,
|
||||
pub network_tokenization_service: Option<SecretStateContainer<NetworkTokenizationService, S>>,
|
||||
pub network_tokenization_supported_connectors: NetworkTokenizationSupportedConnectors,
|
||||
@ -941,11 +940,6 @@ pub struct ServerTls {
|
||||
pub certificate: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone, Default)]
|
||||
pub struct RecipientMails {
|
||||
pub recon: Email,
|
||||
}
|
||||
|
||||
fn deserialize_hashmap_inner<K, V>(
|
||||
value: HashMap<String, String>,
|
||||
) -> Result<HashMap<K, HashSet<V>>, String>
|
||||
|
||||
@ -5,7 +5,6 @@ pub const MAX_NAME_LENGTH: usize = 70;
|
||||
/// The max length of company name and merchant should be same
|
||||
/// because we are deriving the merchant name from company name
|
||||
pub const MAX_COMPANY_NAME_LENGTH: usize = MAX_ALLOWED_MERCHANT_NAME_LENGTH;
|
||||
pub const BUSINESS_EMAIL: &str = "neeraj.kumar@juspay.in";
|
||||
|
||||
pub const RECOVERY_CODES_COUNT: usize = 8;
|
||||
pub const RECOVERY_CODE_LENGTH: usize = 8; // This is without counting the hyphen in between
|
||||
|
||||
@ -33,7 +33,7 @@ pub async fn send_recon_request(
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("Failed to convert recipient's email to UserEmail")?,
|
||||
recipient_email: domain::UserEmail::from_pii_email(
|
||||
state.conf.recipient_emails.recon.clone(),
|
||||
state.conf.email.recon_recipient_email.clone(),
|
||||
)
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("Failed to convert recipient's email to UserEmail")?,
|
||||
|
||||
@ -484,7 +484,7 @@ async fn insert_metadata(
|
||||
state.conf.proxy.https_url.as_ref(),
|
||||
)
|
||||
.await;
|
||||
logger::info!(?send_email_result);
|
||||
logger::info!(prod_intent_email=?send_email_result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -413,9 +413,9 @@ pub struct BizEmailProd {
|
||||
impl BizEmailProd {
|
||||
pub fn new(state: &SessionState, data: ProdIntent) -> UserResult<Self> {
|
||||
Ok(Self {
|
||||
recipient_email: (domain::UserEmail::new(
|
||||
consts::user::BUSINESS_EMAIL.to_string().into(),
|
||||
))?,
|
||||
recipient_email: domain::UserEmail::from_pii_email(
|
||||
state.conf.email.prod_intent_recipient_email.clone(),
|
||||
)?,
|
||||
settings: state.conf.clone(),
|
||||
subject: "New Prod Intent",
|
||||
user_name: data.poc_name.unwrap_or_default().into(),
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use std::{net::IpAddr, str::FromStr};
|
||||
use std::{net::IpAddr, ops::Not, str::FromStr};
|
||||
|
||||
use actix_web::http::header::HeaderMap;
|
||||
use api_models::user::dashboard_metadata::{
|
||||
@ -11,6 +11,7 @@ use diesel_models::{
|
||||
};
|
||||
use error_stack::{report, ResultExt};
|
||||
use masking::Secret;
|
||||
use router_env::logger;
|
||||
|
||||
use crate::{
|
||||
core::errors::{UserErrors, UserResult},
|
||||
@ -284,8 +285,16 @@ fn not_contains_string(value: &Option<String>, value_to_be_checked: &str) -> boo
|
||||
}
|
||||
|
||||
pub fn is_prod_email_required(data: &ProdIntent, user_email: String) -> bool {
|
||||
not_contains_string(&data.poc_email, "juspay")
|
||||
&& not_contains_string(&data.business_website, "juspay")
|
||||
&& not_contains_string(&data.business_website, "hyperswitch")
|
||||
&& not_contains_string(&Some(user_email), "juspay")
|
||||
let poc_email_check = not_contains_string(&data.poc_email, "juspay");
|
||||
let business_website_check = not_contains_string(&data.business_website, "juspay")
|
||||
&& not_contains_string(&data.business_website, "hyperswitch");
|
||||
let user_email_check = not_contains_string(&Some(user_email), "juspay");
|
||||
|
||||
if (poc_email_check && business_website_check && user_email_check).not() {
|
||||
logger::info!(prod_intent_email = poc_email_check);
|
||||
logger::info!(prod_intent_email = business_website_check);
|
||||
logger::info!(prod_intent_email = user_email_check);
|
||||
}
|
||||
|
||||
poc_email_check && business_website_check && user_email_check
|
||||
}
|
||||
|
||||
@ -368,5 +368,15 @@ global_tenant = { schema = "public", redis_key_prefix = "" }
|
||||
[multitenancy.tenants]
|
||||
public = { name = "hyperswitch", base_url = "http://localhost:8080", schema = "public", redis_key_prefix = "", clickhouse_database = "default"}
|
||||
|
||||
[recipient_emails]
|
||||
recon = "recon@example.com"
|
||||
[email]
|
||||
sender_email = "example@example.com"
|
||||
aws_region = ""
|
||||
allowed_unverified_days = 1
|
||||
active_email_client = "SES"
|
||||
recon_recipient_email = "recon@example.com"
|
||||
prod_intent_recipient_email = "business@example.com"
|
||||
|
||||
[email.aws_ses]
|
||||
email_role_arn = ""
|
||||
sts_role_session_name = ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user