Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(users): Move hardcoded email subjects to constants (#6110)
Summer Gram899ec23565f9
diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rsindex 721dd9de1c..28f3f23ccb 100644--- a/crates/router/src/consts.rs+++ b/crates/router/src/consts.rs@@ -87,6 +87,11 @@ pub const EMAIL_TOKEN_TIME_IN_SECS: u64 = 60 * 60 * 24; // 1 day#[cfg(feature = "email")]pub const EMAIL_TOKEN_BLACKLIST_PREFIX: &str = "BET_";+pub const EMAIL_SUBJECT_API_KEY_EXPIRY: &str = "API Key Expiry Notice";+pub const EMAIL_SUBJECT_DASHBOARD_FEATURE_REQUEST: &str = "Dashboard Pro Feature Request by";+pub const EMAIL_SUBJECT_APPROVAL_RECON_REQUEST: &str =+ "Approval of Recon Request - Access Granted to Recon Dashboard";+pub const ROLE_INFO_CACHE_PREFIX: &str = "CR_INFO_";#[cfg(feature = "olap")]diff --git a/crates/router/src/consts/user.rs b/crates/router/src/consts/user.rsindex 6ac2b08e6b..5984a87650 100644--- a/crates/router/src/consts/user.rs+++ b/crates/router/src/consts/user.rs@@ -26,3 +26,10 @@ pub const REDIS_TOTP_SECRET_TTL_IN_SECS: i64 = 15 * 60; // 15 minutespub const REDIS_SSO_PREFIX: &str = "SSO_";pub const REDIS_SSO_TTL: i64 = 5 * 60; // 5 minutes++/// Email subject+pub const EMAIL_SUBJECT_SIGNUP: &str = "Welcome to the Hyperswitch community!";+pub const EMAIL_SUBJECT_INVITATION: &str = "You have been invited to join Hyperswitch Community!";+pub const EMAIL_SUBJECT_MAGIC_LINK: &str = "Unlock Hyperswitch: Use Your Magic Link to Sign In";+pub const EMAIL_SUBJECT_RESET_PASSWORD: &str = "Get back to Hyperswitch - Reset Your Password Now";+pub const EMAIL_SUBJECT_NEW_PROD_INTENT: &str = "New Prod Intent";diff --git a/crates/router/src/core/recon.rs b/crates/router/src/core/recon.rsindex d5f824e0cc..ea3459709c 100644--- a/crates/router/src/core/recon.rs+++ b/crates/router/src/core/recon.rs@@ -39,7 +39,8 @@ pub async fn send_recon_request(.attach_printable("Failed to convert recipient's email to UserEmail")?,settings: state.conf.clone(),subject: format!(- "Dashboard Pro Feature Request by {}",+ "{} {}",+ consts::EMAIL_SUBJECT_DASHBOARD_FEATURE_REQUEST,user_email.expose().peek()),};@@ -145,7 +146,7 @@ pub async fn recon_merchant_account_update(.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to form username")?,settings: state.conf.clone(),- subject: "Approval of Recon Request - Access Granted to Recon Dashboard",+ subject: consts::EMAIL_SUBJECT_APPROVAL_RECON_REQUEST,};if req.recon_status == enums::ReconStatus::Active {diff --git a/crates/router/src/core/user.rs b/crates/router/src/core/user.rsindex 046675f520..c816c73a52 100644--- a/crates/router/src/core/user.rs+++ b/crates/router/src/core/user.rs@@ -74,7 +74,7 @@ pub async fn signup_with_merchant_id(recipient_email: user_from_db.get_email().try_into()?,user_name: domain::UserName::new(user_from_db.get_name())?,settings: state.conf.clone(),- subject: "Get back to Hyperswitch - Reset Your Password Now",+ subject: consts::user::EMAIL_SUBJECT_RESET_PASSWORD,auth_id,};@@ -202,7 +202,7 @@ pub async fn connect_account(recipient_email: domain::UserEmail::from_pii_email(user_from_db.get_email())?,settings: state.conf.clone(),user_name: domain::UserName::new(user_from_db.get_name())?,- subject: "Unlock Hyperswitch: Use Your Magic Link to Sign In",+ subject: consts::user::EMAIL_SUBJECT_MAGIC_LINK,auth_id,};@@ -251,7 +251,7 @@ pub async fn connect_account(let email_contents = email_types::VerifyEmail {recipient_email: domain::UserEmail::from_pii_email(user_from_db.get_email())?,settings: state.conf.clone(),- subject: "Welcome to the Hyperswitch community!",+ subject: consts::user::EMAIL_SUBJECT_SIGNUP,auth_id,};@@ -371,7 +371,7 @@ pub async fn forgot_password(recipient_email: domain::UserEmail::from_pii_email(user_from_db.get_email())?,settings: state.conf.clone(),user_name: domain::UserName::new(user_from_db.get_name())?,- subject: "Get back to Hyperswitch - Reset Your Password Now",+ subject: consts::user::EMAIL_SUBJECT_RESET_PASSWORD,auth_id,};@@ -709,7 +709,7 @@ async fn handle_existing_user_invitation(recipient_email: invitee_email,user_name: domain::UserName::new(invitee_user_from_db.get_name())?,settings: state.conf.clone(),- subject: "You have been invited to join Hyperswitch Community!",+ subject: consts::user::EMAIL_SUBJECT_INVITATION,entity,auth_id: auth_id.clone(),};@@ -840,7 +840,7 @@ async fn handle_new_user_invitation(recipient_email: invitee_email,user_name: domain::UserName::new(new_user.get_name())?,settings: state.conf.clone(),- subject: "You have been invited to join Hyperswitch Community!",+ subject: consts::user::EMAIL_SUBJECT_INVITATION,entity,auth_id: auth_id.clone(),};@@ -959,7 +959,7 @@ pub async fn resend_invite(recipient_email: invitee_email,user_name: domain::UserName::new(user.get_name())?,settings: state.conf.clone(),- subject: "You have been invited to join Hyperswitch Community!",+ subject: consts::user::EMAIL_SUBJECT_INVITATION,entity: email_types::Entity {entity_id,entity_type,@@ -1498,7 +1498,7 @@ pub async fn send_verification_mail(let email_contents = email_types::VerifyEmail {recipient_email: domain::UserEmail::from_pii_email(user.email)?,settings: state.conf.clone(),- subject: "Welcome to the Hyperswitch community!",+ subject: consts::user::EMAIL_SUBJECT_SIGNUP,auth_id,};diff --git a/crates/router/src/services/email/types.rs b/crates/router/src/services/email/types.rsindex 1c4ce79ac8..cedd17828f 100644--- a/crates/router/src/services/email/types.rs+++ b/crates/router/src/services/email/types.rs@@ -417,7 +417,7 @@ impl BizEmailProd {state.conf.email.prod_intent_recipient_email.clone(),)?,settings: state.conf.clone(),- subject: "New Prod Intent",+ subject: consts::user::EMAIL_SUBJECT_NEW_PROD_INTENT,user_name: data.poc_name.unwrap_or_default().into(),poc_email: data.poc_email.unwrap_or_default().into(),legal_business_name: data.legal_business_name.unwrap_or_default(),diff --git a/crates/router/src/workflows/api_key_expiry.rs b/crates/router/src/workflows/api_key_expiry.rsindex b26e9862e8..c04e4c5d57 100644--- a/crates/router/src/workflows/api_key_expiry.rs+++ b/crates/router/src/workflows/api_key_expiry.rs@@ -6,7 +6,7 @@ use router_env::{logger, metrics::add_attributes};use scheduler::{workflows::ProcessTrackerWorkflow, SchedulerSessionState};use crate::{- errors,+ consts, errors,logger::error,routes::{metrics, SessionState},services::email::types::ApiKeyExpiryReminder,@@ -81,7 +81,7 @@ impl ProcessTrackerWorkflow<SessionState> for ApiKeyExpiryWorkflow {);errors::ProcessTrackerError::EApiErrorResponse})?,- subject: "API Key Expiry Notice",+ subject: consts::EMAIL_SUBJECT_API_KEY_EXPIRY,expires_in: *expires_in,api_key_name,prefix,