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

Initial implementation of the invite email sending service #3735

Merged
merged 5 commits into from
Jul 1, 2024
Merged

Conversation

rdimitrov
Copy link
Member

@rdimitrov rdimitrov commented Jun 27, 2024

Summary

The following PR is the initial implementation of the email sending service for invitations.

Details:

  • Adds a new event topic to the message queue for sending emails
  • Adds a common email client interface
  • Adds a client implementation based on AWS SES
  • Adds a config section in server-config

What's left:

  • Test it once there's a configured AWS SES service (Note: If it gets merged before setting up the things on the AWS side of course it will not work but it won't cause any crashes even if the flag is enabled)

Moving away from using a builtin template for the mail content has a separate issue and will be done in a follow-up.

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Example rendering of the template:
image

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

internal/email/awsses.go Outdated Show resolved Hide resolved
dmjb
dmjb previously requested changes Jun 28, 2024
internal/email/email.go Outdated Show resolved Hide resolved
internal/controlplane/handlers_authz.go Show resolved Hide resolved
@rdimitrov rdimitrov force-pushed the mail branch 2 times, most recently from 4a048ed to a905fea Compare June 28, 2024 09:15
@coveralls
Copy link

Coverage Status

coverage: 52.101% (-0.3%) from 52.432%
when pulling a905fea on mail
into d045d12 on main.

@coveralls
Copy link

Coverage Status

coverage: 52.111% (-0.3%) from 52.432%
when pulling a905fea on mail
into d045d12 on main.

Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
@rdimitrov rdimitrov force-pushed the mail branch 2 times, most recently from cc0a318 to b12efed Compare June 28, 2024 14:29
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
@rdimitrov rdimitrov marked this pull request as ready for review June 28, 2024 14:32
@rdimitrov rdimitrov requested a review from a team as a code owner June 28, 2024 14:32
@coveralls
Copy link

Coverage Status

coverage: 51.997% (-0.4%) from 52.439%
when pulling bb39ae1 on mail
into 674252b on main.

@coveralls
Copy link

Coverage Status

coverage: 51.997% (-0.4%) from 52.439%
when pulling bb39ae1 on mail
into 674252b on main.

@coveralls
Copy link

Coverage Status

coverage: 51.997% (-0.4%) from 52.439%
when pulling bb39ae1 on mail
into 674252b on main.

@rdimitrov rdimitrov requested a review from dmjb July 1, 2024 08:19
@rdimitrov rdimitrov dismissed dmjb’s stale review July 1, 2024 09:01

The comment about renaming this was addressed.

@rdimitrov
Copy link
Member Author

@dmjb - The comment about renaming this was addressed. Dismissing this so we can unblock merging the PR. Do get back to me in case you wanted me to address something once you're back from PTO and I'll do a follow-up 👍

@rdimitrov rdimitrov merged commit 5d519d3 into main Jul 1, 2024
20 checks passed
@rdimitrov rdimitrov deleted the mail branch July 1, 2024 09:01
Copy link
Member

@evankanderson evankanderson left a comment

Choose a reason for hiding this comment

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

LGTM, but adding a few comments after-the-fact, because I got to this late.

//nolint:lll
const (
// bodyHTML is the HTML body of the email
bodyHTML = `
Copy link
Member

Choose a reason for hiding this comment

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

Files stored in cmd/server/kodata will be packaged into the application container, though I suspect we actually want to read this from a separate file that's not packaged in the container, so it can be Stacklok-branded without needing to ship the base email as Stacklok-branded.

This is fine for getting started, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this is the initial approach and there'll be a follow-up where we can decide how to distribute the template.

}

// getBodyHTML returns the HTML body for the email based on the message payload
func (e *MailEventPayload) getEmailBodyHTML() string {
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to have this expansion be consistent across different email providers; I don't know if we'd want to actually store the expanded payload in the message at some point in the future where the email sending service might be separate from Minder.

That's something we can adjust in the future, though.

If we make the expansion part of the message, it feels like we could make the different email senders simply Register directly, rather than needing to go through the MailEventHandler construct.

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed in #3783

Comment on lines +211 to +212
// Register the email manager to handle email invitations
mailClient, err := email.NewAWSSES(cfg.Email.AWSSES.Sender, cfg.Email.AWSSES.Region)
Copy link
Member

Choose a reason for hiding this comment

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

This feels like we should only do this block if cfg.Email.AWSSES.Sender is non-empty, but I guess we'll do that in the future to allow local development to not need AWS credentials set up.

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed in #3783

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.

5 participants