Conversation
maxn990
left a comment
There was a problem hiding this comment.
a couple of super quick things, but overall looks really good!! 🥳 🥳 🥳
|
|
||
| @Post('/email') | ||
| async sendEmail(@Body() sendEmailDTO: SendEmailDTO): Promise<void> { | ||
| const { toEmail, subject, bodyHtml, attachments } = sendEmailDTO; | ||
|
|
||
| await this.emailsService.sendEmail(toEmail, subject, bodyHtml, attachments); | ||
| } |
There was a problem hiding this comment.
this shouldn't be a public route. right now this would mean that, once deployed, anyone who could access the api could send unlimited emails from our aws account. if you've finished role based auth, i would recommend adding a guard, otherwise commenting this out for now
There was a problem hiding this comment.
it was going to be changed after we merged in the role based auth. i can just comment it out and whoever tests this next can uncomment
| public async sendEmail( | ||
| recipientEmail: string, | ||
| subject: string, | ||
| bodyHTML: string, | ||
| attachments?: EmailAttachment[], | ||
| ): Promise<unknown> { | ||
| return this.amazonSESWrapper.sendEmails( | ||
| [recipientEmail], | ||
| subject, | ||
| bodyHTML, | ||
| attachments, | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
is there a reason the method name here, sendEmail, is singular but it is a wrapper for sendEmails, which is plural?
There was a problem hiding this comment.
realized there was a mistake with the recipientEmails not accepting multiple. just fixed it.
|
|
||
| @Post('/email') | ||
| async sendEmail(@Body() sendEmailDTO: SendEmailDTO): Promise<void> { | ||
| const { toEmail, subject, bodyHtml, attachments } = sendEmailDTO; | ||
|
|
||
| await this.emailsService.sendEmail(toEmail, subject, bodyHtml, attachments); | ||
| } |
|
|
||
| @Post('/email') | ||
| async sendEmail(@Body() sendEmailDTO: SendEmailDTO): Promise<void> { | ||
| const { toEmail, subject, bodyHtml, attachments } = sendEmailDTO; | ||
|
|
||
| await this.emailsService.sendEmail(toEmail, subject, bodyHtml, attachments); | ||
| } |
ℹ️ Issue
Closes #109
📝 Description
This ticket creates an initial part of our email automation. This was actually very straightforward, and followed a similar architecture that JPAL uses. To get this working, I needed to verify my email on AWS SES, which can be done through the following:
AWS_SES_SENDER_EMAIL(all sender emails must be verified). THIS WILL BE UPDATED IN THE README AFTER WE MERGE IN THE ENVIRONMENT VARIABLE PR.Additionally, here is some logic of what each of the file's purposes serve:
awsSesClient.factory.tsserves as the main configuration for the SES Client. It provides the user's access key and id to allow them to use the service API. It also provides a client to be injected later on.awsSes.wrapper.tsinjects this factory into the constructor, making it a valid client that has all SES functionality. This allows us to easily setup the proper parameters to send an email with varying complexity (supporting image attachments as well).email.service.tsprovides the service function that we will actually be calling with our API. All controllers will likely need to use this in their module which we have setup. This allows them to send a simple DTO and send an email just like that.✔️ Verification
I made sure that we could send emails as is, as well as one with email attachments. I created a dummy endpoint for right now in the
pantries.controller.tsfile.🏕️ (Optional) Future Work / Notes
The emails are currently being marked as spam for some reason, not qutie sure as to why yet. Perhaps there is an AWS setting to change that.