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

Email SeS implementation #19

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Email SeS implementation #19

wants to merge 7 commits into from

Conversation

Mayank808
Copy link
Collaborator

@Mayank808 Mayank808 commented Dec 30, 2024

Notion ticket link

Setup Email System

NOTE THIS IS A PR for feedback not to merge.
Will be removing email.py route as its simply there right now for testing
will be removing todos and adding comments
will be removing any prints or updating them to logs

Implementation description

  • Implemented Email sending using amazon ses.
  • Create email templates at startup
  • use email templates to send single and bulk emails to users with predefined templates
  • Email templates can use inline CSS need to define a text file with only text for each respective email

Process to create a new Email Template to use:

  1. Create the HTML and Text files for the new template. Use inline CSS and direct hosted links to any images required.
  2. Update backend/app/utilities/ses/ses_templates.json to include template name subject and absolute paths to the above file
  3. Create a new data class Type for the Email template
@dataclass
class NewEmailTemplatData():
    name: str
    date: str
    random: int
  1. Update Email template enum to include the file name of the template defined in amazon ses and the ses_templates.json file
class EmailTemplate(Enum):
   NEWEMAILTEMPLATE = "newemailtemplate"
  1. Use in code to send emails using email service
email_service.send_email(
    template=EmailTemplate.NEWEMAILTEMPLATE,
    content=EmailContent[NewEmailTemplatData](
        recipient=recipient, 
        data=NewEmailTemplatData(name=user_name, date="2021-12-01", random: 20)
    ),
)

Todo

  • Add bulk send email after general flow is good
  • Look into schedule send
  • Clean up logging and comments
  • Remove email.py route
  • Unit Testing
  • File clean up

Steps to test

  1. Simply hit the /email/send-test email route when running the be on local

What should reviewers focus on?

  • Focus on overall design of things and how things are laid out as this pr still needs to be cleaned up.
  • How templates are defined, what folders code blocks should be stored in
  • Are we okay with running the email template check on startup
  • Will be removing email.py route as its simply there right now for testing

Checklist

  • My PR name is descriptive and in imperative tense
  • My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits
  • I have run the appropriate linter(s)
  • I have requested a review from the PL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR

@Mayank808 Mayank808 requested a review from mslwang December 30, 2024 06:25
Copy link
Collaborator

@mslwang mslwang left a comment

Choose a reason for hiding this comment

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

Great work here! Left some general comments

@Mayank808 Mayank808 requested a review from ebwu95 February 12, 2025 01:03
@Mayank808 Mayank808 marked this pull request as ready for review February 12, 2025 01:10
@Mayank808 Mayank808 requested a review from mmiqball February 12, 2025 01:33
Copy link
Contributor

@ebwu95 ebwu95 left a comment

Choose a reason for hiding this comment

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

LGTM! Great work

models.run_migrations()
initialize_firebase()
ensure_ses_templates()
# models.run_migrations()
Copy link
Contributor

Choose a reason for hiding this comment

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

Were these commented because of logging issues?

Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: why is the route name under email_test? Is this just supposed to be temporary?

Copy link
Collaborator

@mmiqball mmiqball left a comment

Choose a reason for hiding this comment

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

looks good to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants