Add recurring job to notify group admins of bounces#2088
Merged
stephencdaly merged 6 commits intoMay 13, 2026
Conversation
b91abbd to
c40e2a3
Compare
b0e5539 to
910c3f7
Compare
This makes a request to /api/v2/forms/:form_id/group to get the group for a form. The group response includes the group name, names and email addresses of the group admins and the organisation details - name and details of organisation admins. Also add factories for a group and and an admin user included in the groups API response.
Add mailer with a method to send bounce notification emails to group admins using Notify.
Add a job to find all forms that have deliveries that bounced on the given date and send notification emails to the group admins for those forms. This accepts a date as a parameter so that the job can be retried if it fails and still send notifications for the given date. This will be scheduled by another job run on a daily schedule.
We want the job that sends bounce notifications to run on a schedule every day, and we want it to be retryable if it fails. Add a job that will run on a schdedule to enqueue the SendBounceNotificationsJob to send bounce notifications for the previous day so that retrying the job will send bounces for that day.
We'll add the schedule on production environments when we've also added sending notifications to Organisation Admins after a week if the delivery is still marked as bounced.
910c3f7 to
c68818e
Compare
Contributor
|
🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-2088.submit.review.forms.service.gov.uk/ It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready For the sign in details and more information, see the review apps wiki page. |
chao-xian
approved these changes
May 13, 2026
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.
What problem does this pull request solve?
Trello card: https://trello.com/c/CsEqMtDL
Adds 2 jobs:
We only want to turn this on when we're notifying Organisation Admins after a week has passed if deliveries are still marked as bounced. Instead of adding a feature flag, I thought it was easier to just not add the recurring schedule to recurring.yml until notifying org admins is ready.
Testing
This is a little tricky to test, but can be tested locally by:
failed_at(to yesterday),failure_reason,failure_details. The failure_details should be{ "bounceType" => "Permanent" }for a hard bounce and{ "bounceType" => "Transient" }for a soft bounce.recurring.ymlto schedule theschedule_bounce_notifications_jobrecurring task to be on a schedule that will run soon (e.g. every minute or a set time in the future)../bin/jobswith:SETTINGS__GOVUK_NOTIFY__API_KEY=your-test-notify-key PGGSSENCMODE="disable" ASSUME_DEV_IAM_ROLE=true ./bin/jobsI've tested that it works by pushing the branch to dev, and with different types of bounces by testing locally, so if you're satisfied by my testing you don't need to test again.
Email for a hard bounce (tested on dev):
Email for a soft bounce (tested locally). The deadline date is a bit odd for this one, but that's just because I messed around with dates of delivery records in the rails console, and locally we delete submissions after 5 minutes:
Things to consider when reviewing