codersforcauses / repair-lab

https://repair-labs.vercel.app
MIT License
8 stars 3 forks source link

Send email on successful repair request #152

Closed dct0 closed 7 months ago

dct0 commented 11 months ago

Basic Information

Send confirmation email to client when a repair request is created. The template is already created in src/email/emails.

Additionally, to avoid spam during testing, make this feature togglable. Consider adding a metadata attribute to the clerk user like disableEmailConfirmations or add some environment variable

Other Information

We are using AWS SES to send emails with React Email. Let me know if you have any issues with the access key.

github-actions[bot] commented 11 months ago

Branch issue-152-Send_email_on_successful_repair_request created!

tonglam commented 11 months ago

Initial thoughts:

  1. When and how to trigger the sending action.
  2. Avoid sending duplicate emails; perhaps, recording the sending status is necessary.
  3. How to trace what was actually sent to clients after the sending action.
  4. If the sending action failed, should we make up for it? How many times should we retry?
  5. What if a client requests a resend?
  6. What if the template changes?
dct0 commented 11 months ago
  1. In the POST of /api/repair-request. It's missing error handling and error states currently, which can be added in this work
  2. We could store the created email contents in the database, but I think this can be left to a separate issue
  3. Same thing here, logging isn't a huge concern for MVP
  4. Not sure about this, we'll have to do some research on what AWS SES can give us. Otherwise, if the email isn't received, we can add a button on the client's repair requests page to resend the email
  5. Leave it to a separate email
  6. Given we only have one template right now, I don't think it's justified to store the email template in a database so we don't have to redeploy every time the template changes.
tonglam commented 10 months ago

What have done:

  1. adding aws ses document in email readme;
  2. adding ses service in /service/sendEmail.ts;
  3. adding sending email after create repaire-request in .../repair-request/index.ts.

Todo:

  1. adding sending switch;
  2. handling sending error;
  3. testing.
tonglam commented 10 months ago
image

Email sent successfully.

Todo:

  1. Fix the email template; the HTML content for the email doesn't work currently.
  2. Add a unit test for creating repair requests, including sending confirmation emails.
  3. Implement SES mock in the test environment.
tonglam commented 10 months ago
image

Template Email sent successfully.

Todo:

tonglam commented 10 months ago

Mock Email:

image

Real Email:

image
dct0 commented 7 months ago

Completed in #193