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(ses_email): add email services to hyperswitch #2977

Merged
merged 27 commits into from
Nov 29, 2023

Conversation

Narayanbhat166
Copy link
Member

@Narayanbhat166 Narayanbhat166 commented Nov 24, 2023

Type of Change

  • New feature

Description

This PR supports integrating multiple email services with hyperswitch. SES support is added in this PR.

Motivation and Context

There are two traits created in the external_services. In order to implement an email client, The EmailClient trait should be implemented.

How did you test it?

  • Setup email service locally and send the email.
Screenshot 2023-11-24 at 4 38 45 PM

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible
  • I added a CHANGELOG entry if applicable

@Narayanbhat166 Narayanbhat166 added the C-feature Category: Feature request or enhancement label Nov 24, 2023
@Narayanbhat166 Narayanbhat166 added this to the November 2023 Release milestone Nov 24, 2023
@Narayanbhat166 Narayanbhat166 self-assigned this Nov 24, 2023
@Narayanbhat166 Narayanbhat166 requested review from a team as code owners November 24, 2023 11:10
Copy link
Member

@SanchithHegde SanchithHegde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than that, looks good to me!

@Chethan-rao Can we also update the API key expiry task to send richer HTML emails, maybe in a separate PR?

state
.email_client
.clone()
.send_email(
email_id.ok_or_else(|| errors::ProcessTrackerError::MissingRequiredField)?,
"API Key Expiry Notice".to_string(),
format!("Dear Merchant,\n
It has come to our attention that your API key will expire in {expires_in} days. To ensure uninterrupted access to our platform and continued smooth operation of your services, we kindly request that you take the necessary actions as soon as possible.\n\n
Thanks,\n
Team Hyperswitch"),
)
.await
.map_err(|_| errors::ProcessTrackerError::FlowExecutionError {
flow: "ApiKeyExpiryWorkflow",
})?;

crates/external_services/Cargo.toml Outdated Show resolved Hide resolved
crates/external_services/src/email.rs Show resolved Hide resolved
crates/external_services/src/email/ses.rs Outdated Show resolved Hide resolved
crates/external_services/src/email/ses.rs Outdated Show resolved Hide resolved
crates/external_services/src/email/ses.rs Outdated Show resolved Hide resolved
crates/external_services/src/email/ses.rs Outdated Show resolved Hide resolved
crates/external_services/src/email/ses.rs Outdated Show resolved Hide resolved
crates/router/src/core/user.rs Outdated Show resolved Hide resolved
crates/router/src/services/email/assets/mod.rs Outdated Show resolved Hide resolved
pub fn get_html_body(email_body: EmailBody) -> String {
match email_body {
EmailBody::Verify { link } => {
format!(include_str!("assets/verify.html"), link = link)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please use tera instead of using format!()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crates/external_services/src/email.rs Outdated Show resolved Hide resolved
config/development.toml Outdated Show resolved Hide resolved
ThisIsMani
ThisIsMani previously approved these changes Nov 28, 2023
@Narayanbhat166
Copy link
Member Author

No test cases need to be tested here.

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Nov 29, 2023
Merged via the queue into main with commit 5f5e895 Nov 29, 2023
9 of 12 checks passed
@Gnanasundari24 Gnanasundari24 deleted the add_email_client branch November 29, 2023 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants