Repository navigation
Aakash - Jobs Component: cap application confirmation emails per address and per day - #2413
Open
vidiyala99 wants to merge 2 commits into
Open
vidiyala99 wants to merge 2 commits into
vidiyala99 wants to merge 2 commits into
Conversation
|
This was referenced Oct 21, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Bug 62 (Jobs Component - Cap Application Confirmation Emails): each form allows one application per address, but nothing limited how many forms one address could be used on. Anyone could use the public form to make One Community email a victim once per open form, or burn the shared Gmail quota that password-reset emails also depend on.
Fixes # Bug 62 (Jobs Component - Cap Application Confirmation Emails)
Related PRS (if any):
HGNRest#2411 (escape applicant input in the same email) edits the email body in the same function. This PR only adds a guard at the top, and the two merge cleanly.
Main changes explained:
src/utilities/confirmationEmailCap.js:shouldSendConfirmation(email)counts saved applications in the last 24 hours (rolling window), for the applicant's address and across all forms. A confirmation email is skipped when the address has more than 3 or the total is more than 300. The count runs after the application is saved, so it includes the current one: the 3rd application from one address in 24 hours still gets an email and the 4th does not; globally the 300th gets one and the 301st does not.src/controllers/collaborationController.js:sendApplicationConfirmationEmailchecks the cap first. When capped, the application is still saved, the response is the same success response, and one warning is logged (cap name, masked address such asa***@example.com, the counts).src/models/jobApplicationsModel.js: indexes{ email: 1, createdAt: -1 }and{ createdAt: -1 }so both counts stay cheap. Mongoose builds them on deploy, no migration.src/utilities/__tests__/confirmationEmailCap.test.js(new, 11 cases) and 4 new cases insrc/controllers/collaborationController.test.js: sent under the cap, sent at 3, skipped at 4 while the application is still saved and the response stays 201, global cap, only the last 24 hours counts, fails open on a count error, logs never contain the full address, and the index check.How to test:
npm installnpx jest --runInBand src/utilities/__tests__/confirmationEmailCap.test.js src/controllers/collaborationController.test.js(27 tests pass)Screenshots or videos of changes:
Test output (jest): 2 suites, 27 tests passed.
Note: