Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(themes): Add email configuration support for themes #7580

Merged
merged 14 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1006,8 +1006,8 @@ file_storage_backend = "file_system" # Theme storage backend to be used

[theme.email_config]
entity_name = "Hyperswitch" # Name of the entity to be showed in emails
entity_logo_url = "https://example.com/logo.svg" # Logo URL of the entity to be used in emails
foreground_color = "#000000" # Foreground color of email text
entity_logo_url = "https://app.hyperswitch.io/email-assets/HyperswitchLogo.png" # Logo URL of the entity to be used in emails
foreground_color = "#111326" # Foreground color of email text
primary_color = "#006DF9" # Primary color of email body
background_color = "#FFFFFF" # Background color of email body

Expand Down
5 changes: 1 addition & 4 deletions crates/router/src/consts/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ pub 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";
pub const EMAIL_SUBJECT_WELCOME_TO_COMMUNITY: &str =
"Thank you for signing up on Hyperswitch Dashboard!";
Expand Down
11 changes: 3 additions & 8 deletions crates/router/src/core/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,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: consts::user::EMAIL_SUBJECT_RESET_PASSWORD,

auth_id,
theme_id: theme.as_ref().map(|theme| theme.theme_id.clone()),
theme_config: theme
Expand Down Expand Up @@ -307,7 +307,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: consts::user::EMAIL_SUBJECT_MAGIC_LINK,

auth_id,
theme_id: theme.as_ref().map(|theme| theme.theme_id.clone()),
theme_config: theme
Expand Down Expand Up @@ -363,7 +363,6 @@ pub async fn connect_account(
let magic_link_email = email_types::VerifyEmail {
recipient_email: domain::UserEmail::from_pii_email(user_from_db.get_email())?,
settings: state.conf.clone(),
subject: consts::user::EMAIL_SUBJECT_SIGNUP,
auth_id,
theme_id: theme.as_ref().map(|theme| theme.theme_id.clone()),
theme_config: theme
Expand Down Expand Up @@ -516,7 +515,6 @@ 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: consts::user::EMAIL_SUBJECT_RESET_PASSWORD,
auth_id,
theme_id: theme.as_ref().map(|theme| theme.theme_id.clone()),
theme_config: theme
Expand Down Expand Up @@ -928,7 +926,6 @@ 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: consts::user::EMAIL_SUBJECT_INVITATION,
entity,
auth_id: auth_id.clone(),
theme_id: theme.as_ref().map(|theme| theme.theme_id.clone()),
Expand Down Expand Up @@ -1085,7 +1082,6 @@ async fn handle_new_user_invitation(
recipient_email: invitee_email,
user_name: domain::UserName::new(new_user.get_name())?,
settings: state.conf.clone(),
subject: consts::user::EMAIL_SUBJECT_INVITATION,
entity,
auth_id: auth_id.clone(),
theme_id: theme.as_ref().map(|theme| theme.theme_id.clone()),
Expand Down Expand Up @@ -1237,7 +1233,7 @@ pub async fn resend_invite(
recipient_email: invitee_email,
user_name: domain::UserName::new(user.get_name())?,
settings: state.conf.clone(),
subject: consts::user::EMAIL_SUBJECT_INVITATION,

entity: email_types::Entity {
entity_id,
entity_type,
Expand Down Expand Up @@ -1896,7 +1892,6 @@ 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: consts::user::EMAIL_SUBJECT_SIGNUP,
auth_id,
theme_id: theme.as_ref().map(|theme| theme.theme_id.clone()),
theme_config: theme
Expand Down
Loading
Loading