-
Notifications
You must be signed in to change notification settings - Fork 87
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: automate critical bounce handling #318
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks lgtm, with some minor changes suggested. could you also update the import alias to use bounceService
instead of snsService
? naming is hard, but doing it consistently will help to keep it simple for everyone.
a7624b2
to
c41d27b
Compare
@liangyuanruo @karrui I'm currently writing new tests for the refactored code, but meanwhile if you can spare some time, could you help me take a look at this commit pls? I'm not sure if I'm allocating responsibility between the controller and service correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
partial comments
e6d6e35
to
813ec66
Compare
bd2490e
to
264e6e9
Compare
264e6e9
to
6bd08c8
Compare
Problem
Our work to handle critical bounces is generally repetitive. We usually have to send the same email to admins repeatedly, filling in the blanks for form titles and URLs ourselves. Moreover, when all bounces are permanent, the form needs to be deactivated. This work should be automated.
Solution
Automate sending of critical bounce emails as well as form deactivation.
The changes can be reviewed in commit order, but here is a list of changes and refactors:
mail.service.ts
andmail.util.ts
were moved intosrc/types/mail.ts
.sendBounceNotification
function was implemented inmail.service.ts
, and tests were implemented inmail.service.spec.ts
.deactivateById
was added to the Form schema for form deactivation, and tests were implemented inform.server.model.spec.ts
.hasAlarmed
in the Bounce schema was changed tohasAutoEmailed
, to reflect whether an automated email has been sent for this form for this critical bounce. Bounce schema was updated to store abounceType
for every email address. This is important in order to be sure that all emails have permanently bounced before deactivating the form.merge
was changed toupdateBounceInfo
, and now takes in only an SNS notification instead of a Bounce document as well as an SNS notification. It didn't make sense to derive a Bounce document from an SNS notification, then pass both to themerge
method. HenceupdateBounceInfo
now updates the Bounce document purely based on the notification.areAllPermanentBounces
,getEmails
andsetHasAutoEmailed
were implemented on the Bounce schema for convenience.src/app/views
.bounce.service.ts
was updated to compute the list of admins/collaborators who were not amongst the bounced recipients, and callmailService.sendBounceNotification
to email them.src/app/modules/bounce/__tests__
to reflect all of the above changes.Screenshots
Tests
hasBounced: true
andbounceType: Permanent
for the invalid email recipient.Critical bounce
has been changed toBounced submission
.