feat(users): Send welcome to community email in magic link signup (#6639)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Mani Chandra
2024-11-26 13:46:56 +05:30
committed by GitHub
parent 710186f035
commit 03423a1f76
4 changed files with 350 additions and 5 deletions

View File

@ -41,3 +41,5 @@ pub const EMAIL_SUBJECT_INVITATION: &str = "You have been invited to join Hypers
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!";

View File

@ -246,26 +246,41 @@ pub async fn connect_account(
)
.await?;
let email_contents = email_types::VerifyEmail {
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,
};
let send_email_result = state
let magic_link_result = state
.email_client
.compose_and_send_email(
Box::new(email_contents),
Box::new(magic_link_email),
state.conf.proxy.https_url.as_ref(),
)
.await;
logger::info!(?send_email_result);
logger::info!(?magic_link_result);
let welcome_to_community_email = email_types::WelcomeToCommunity {
recipient_email: domain::UserEmail::from_pii_email(user_from_db.get_email())?,
subject: consts::user::EMAIL_SUBJECT_WELCOME_TO_COMMUNITY,
};
let welcome_email_result = state
.email_client
.compose_and_send_email(
Box::new(welcome_to_community_email),
state.conf.proxy.https_url.as_ref(),
)
.await;
logger::info!(?welcome_email_result);
return Ok(ApplicationResponse::Json(
user_api::ConnectAccountResponse {
is_email_sent: send_email_result.is_ok(),
is_email_sent: magic_link_result.is_ok(),
user_id: user_from_db.get_user_id().to_string(),
},
));

View File

@ -0,0 +1,306 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Email Template</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
<style>
@media only screen and (max-width: 600px) {
.card-container {
display: block !important;
width: 100% !important;
padding: 0 !important;
}
.card {
width: 100% !important;
max-width: 100% !important;
margin-bottom: 15px !important;
display: block !important;
box-sizing: border-box;
}
.repocard,
.communitycard,
.devdocs-card {
width: 100% !important;
padding: 0 !important;
margin-bottom: 10px !important;
}
.card-content {
width: 100% !important;
max-width: 100% !important;
height: auto !important;
min-height: 100px !important;
padding: 20px 0 0 20px !important;
box-sizing: border-box;
}
.docscard-content {
width: 100% !important;
max-width: 100% !important;
height: auto !important;
min-height: 100px !important;
padding: 0 20px 0 20px !important;
box-sizing: border-box;
}
.divider {
width: 100% !important;
padding: 0 !important;
}
.footer-section {
text-align: center !important;
margin: 0 auto;
width: 100%;
}
td.card-container,
td.card {
width: 100% !important;
padding: 0 !important;
display: block !important;
}
.logo-section {
text-align: center !important;
width: 100% !important;
}
.logo-section img {
display: block;
margin: 0 auto;
}
}
a.card-link {
text-decoration: none !important;
color: inherit !important;
}
.card-content td {
color: #151A1F !important;
}
.card-content td img {
display: block !important;
}
</style>
</head>
<body style="margin: 0; padding: 0; background-color: #f6f6f8; font-family: 'Inter', Arial, sans-serif;">
<center>
<table width="100%" cellspacing="0" cellpadding="0"
style="border-spacing: 0; margin: 0; padding: 0; background-color: #f6f6f8;">
<tr>
<td align="center">
<table role="presentation" width="600" cellspacing="0" cellpadding="0" class="container"
style="max-width: 600px; background-color: #ffffff; border-radius: 10px; border-collapse: collapse;">
<!-- Header Section -->
<tr>
<td align="center" bgcolor="#283652"
style="padding: 40px 30px; color: white; border-top-left-radius: 20px; border-top-right-radius: 20px;">
<table width="100%" role="presentation" cellspacing="0" cellpadding="0">
<tr>
<td align="left">
<img src="https://app.hyperswitch.io/assets/welcome-email/logotext.png"
alt="Hyperswitch Logo" width="150"
style="display: block; margin-bottom: 20px;">
</td>
</tr>
<tr>
<td align="left"
style="font-size: 36px; line-height: 40px; font-weight: 500; color: white;">
Welcome to
<span style="font-weight: 700;">Hyperswitch</span>
<img src="https://app.hyperswitch.io/assets/welcome-email/star.png"
alt="Star Icon" width="30"
style="display: inline-block; vertical-align: middle; position: relative; top: -3px; margin-left: -2px;">
</td>
</tr>
</table>
</td>
</tr>
<!-- Body Section -->
<tr>
<td align="left"
style="padding: 30px; background-color: #FFFFFF; color: #151A1F; font-size: 16px; font-family: 'Inter', Arial, sans-serif; font-weight: 400; line-height: 23.68px; text-align: left;">
<p style="margin-bottom: 20px; font-weight: 500;">Hello,</p>
<p style="margin-bottom: 20px;">I wanted to reach out and introduce our community to
you.</p>
<p style="margin-bottom: 20px;">Im Neeraj. I work in Community Growth here at
Hyperswitch. We are a bunch of passionate people solving for payment diversity,
complexity, and innovation. Juspay, our parent organization, processes 125 Mn
transactions every day and has been providing payment platform solutions to large
digital enterprises for the past 12 years. We wish to empower global businesses to
expand their reach and enhance customer experiences through diverse payment
solutions.</p>
<p style="margin-bottom: 20px;">Our mission is to provide a Fast, Reliable, Affordable &
Transparent payments platform, allowing businesses the flexibility to choose between
open-source and SaaS solution.</p>
</td>
</tr>
<!-- CTA Cards Section (GitHub & Slack) -->
<tr>
<td align="center" style="padding: 0 30px;">
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<!-- GitHub Repo Card -->
<td width="50%" class="card" valign="top" style="padding-right: 10px;">
<a href="https://github.com/juspay/hyperswitch" target="_blank"
class="card-link">
<table class="card-content" width="100%" cellspacing="0" cellpadding="0"
style="background-color: #F6F6F6; border-radius: 16px; padding: 20px 0 0 20px;">
<tr>
<td align="left"
style="vertical-align: top; font-size: 22px; font-weight: 600; padding-right: 20px;">
Star <br /> our repo
</td>
<td align="right"
style="vertical-align: top; padding: 0 20px 0 0;">
<img src="https://app.hyperswitch.io/assets/welcome-email/repoArrow.png"
alt="Arrow Icon" width="24" height="24"
style="border-radius: 50%; padding: 7px; background-color: #fff;">
</td>
</tr>
<tr>
<td colspan="2" align="right">
<img src="https://app.hyperswitch.io/assets/welcome-email/github-logo1.png"
alt="GitHub Icon" width="98" height="98"
style="display: block;">
</td>
</tr>
</table>
</a>
</td>
<!-- Slack Community Card -->
<td width="50%" class="card" valign="top" style="padding-left: 10px;">
<a href="https://hyperswitch-io.slack.com/join/shared_invite/zt-2jqxmpsbm-WXUENx022HjNEy~Ark7Orw#/shared-invite/email"
target="_blank" class="card-link">
<table class="card-content" width="100%" cellspacing="0" cellpadding="0"
style="background-color: #F6F6F6; border-radius: 16px; padding: 20px 0 0 20px;">
<tr>
<td align="left"
style="vertical-align: top; font-size: 22px; font-weight: 600; padding-right: 20px;">
Join our <br /> Community
</td>
<td align="right"
style="vertical-align: top; padding: 0 20px 0 0;">
<img src="https://app.hyperswitch.io/assets/welcome-email/communityArrow.png"
alt="Arrow Icon" width="24" height="24"
style="border-radius: 50%; padding: 7px; background-color: #fff;">
</td>
</tr>
<tr>
<td colspan="2" align="right">
<img src="https://app.hyperswitch.io/assets/welcome-email/slack.png"
alt="Slack Icon" width="98" height="98"
style="display: block;">
</td>
</tr>
</table>
</a>
</td>
</tr>
</table>
</td>
</tr>
<!-- Read Dev Docs Section -->
<tr>
<td style="padding: 10px 30px 0 30px ;">
<a href="https://api-reference.hyperswitch.io/introduction" target="_blank"
class="card-link">
<table class="docscard-content" width="100%" cellspacing="0" cellpadding="0"
style="background-color: #FFEFEF; border-radius: 16px; padding: 20px;">
<tr>
<td style="vertical-align: middle;">
<table>
<tr>
<td style="vertical-align: middle;">
<img src="https://app.hyperswitch.io/assets/welcome-email/docs.png"
alt="docs icon" width="24" height="29"
style="margin-right: 10px;">
</td>
<td style="vertical-align: middle;">
<span style="font-size: 22px; font-weight: 600;">Read dev
docs</span>
</td>
</tr>
</table>
</td>
<td align="right" style="vertical-align: middle;">
<img src="https://app.hyperswitch.io/assets/welcome-email/docsArrow.png"
alt="Arrow Icon" width="24" height="24"
style="border-radius: 50%; padding: 7px; background-color: #fff;">
</td>
</tr>
</table>
</a>
</td>
</tr>
<!-- Divider and Footer Section -->
<tr>
<td style="padding: 40px 0 0 0;">
<!-- Divider (Top Border) -->
<table width="100%" class="divider" cellpadding="0" cellspacing="0"
style="border-top: 1px solid #F2F2F2;">
<tr>
<td align="center">
<table cellspacing="0" cellpadding="0"
style="margin: 0 auto; padding: 30px 0; max-width: 378px; width: 100%;">
<tr>
<td align="center" style="padding: 0;" class="logo-section">
<img src="https://app.hyperswitch.io/assets/welcome-email/logo.png"
alt="Icon" width="82" height="40" style="display: block;">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- Footer Section with max-width 600px -->
<tr>
<td align="center" style="padding: 16px 4px 0 4px; background-color: #f6f6f8;">
<table width="100%" cellspacing="0" cellpadding="0" style="max-width: 601px;">
<tr>
<!-- Follow us on and Social Media Icons -->
<td align="left"
style="font-family: 'Inter', Arial, sans-serif; font-size: 12px; font-weight: 500; line-height: 16px; color: #63605F;">
Follow us on
<a href="https://x.com/hyperswitchio"
style="margin-right: 10px; text-decoration: none;">
<img src="https://app.hyperswitch.io/assets/welcome-email/twitter.png" alt="Twitter"
width="14" height="14" style="vertical-align: -3px;">
</a>
<a href="https://www.linkedin.com/company/hyperswitch/" style="text-decoration: none;">
<img src="https://app.hyperswitch.io/assets/welcome-email/linkedin.png"
alt="LinkedIn" width="13.33" height="13.33" style="vertical-align: -3px;">
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</body>
</html>

View File

@ -57,6 +57,7 @@ pub enum EmailBody {
api_key_name: String,
prefix: String,
},
WelcomeToCommunity,
}
pub mod html {
@ -145,6 +146,9 @@ Email : {user_email}
prefix = prefix,
expires_in = expires_in,
),
EmailBody::WelcomeToCommunity => {
include_str!("assets/welcome_to_community.html").to_string()
}
}
}
}
@ -505,3 +509,21 @@ impl EmailData for ApiKeyExpiryReminder {
})
}
}
pub struct WelcomeToCommunity {
pub recipient_email: domain::UserEmail,
pub subject: &'static str,
}
#[async_trait::async_trait]
impl EmailData for WelcomeToCommunity {
async fn get_email_data(&self) -> CustomResult<EmailContents, EmailError> {
let body = html::get_html_body(EmailBody::WelcomeToCommunity);
Ok(EmailContents {
subject: self.subject.to_string(),
body: external_services::email::IntermediateString::new(body),
recipient: self.recipient_email.clone().into_inner(),
})
}
}