Skip to content

Send bounce notifications to org admins after a week#2089

Merged
stephencdaly merged 6 commits into
mainfrom
send-bounce-notifications-to-org-admins-after-7-days
May 14, 2026
Merged

Send bounce notifications to org admins after a week#2089
stephencdaly merged 6 commits into
mainfrom
send-bounce-notifications-to-org-admins-after-7-days

Conversation

@stephencdaly
Copy link
Copy Markdown
Contributor

@stephencdaly stephencdaly commented May 11, 2026

What problem does this pull request solve?

Trello card: https://trello.com/c/WmCipXbC

A week after we've contacted group admins about bounced email deliveries, contact the organisation admins.

We contact group admins the day after the bounce, so contact organisation admins 8 days after the bounce.

Re-use the same Notify template and Jobs for sending to organisation admins. Update the ScheduleBounceNotificationsJob to schedule another SendBounceNotificationsJob pass in different parameters for the bounced_on_date and user_role (:group_admin or (:organisation_admin)

Testing

I've tested this on dev. See screenshots below.

Note that to test I temporarily changed it to email org admins after 2 days rather than 8 so it would send the email for some bounces I had already triggered, which is reflected in the dates in the screenshotted email.

Email to org admins:

Screenshot 2026-05-13 at 16 45 35

Email to group admins (should be unchanged by this PR):

Screenshot 2026-05-13 at 16 16 11

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Do the end to end tests need updating before these changes will pass?
  • Has all relevant documentation been updated?

@stephencdaly stephencdaly changed the title Send bounce notifications to org admins 7 days after sending to group admins Send bounce notifications to org admins after a week May 11, 2026
@stephencdaly stephencdaly force-pushed the add-recurring-job-to-notify-group-admins-of-bounces branch 2 times, most recently from b0e5539 to 910c3f7 Compare May 12, 2026 11:33
@stephencdaly stephencdaly force-pushed the send-bounce-notifications-to-org-admins-after-7-days branch from 0feee7e to 8fdd0f5 Compare May 12, 2026 11:59
@stephencdaly stephencdaly force-pushed the add-recurring-job-to-notify-group-admins-of-bounces branch from 910c3f7 to c68818e Compare May 13, 2026 12:52
Base automatically changed from add-recurring-job-to-notify-group-admins-of-bounces to main May 13, 2026 14:40
Most of the email content is the same when we're sending bounce
notifications to org admins and group admins. Re-use the same email
template for sending notifications to org admins and provide an
additional boolean personalisations so we can include slightly
different content for org and group admins.
@stephencdaly stephencdaly force-pushed the send-bounce-notifications-to-org-admins-after-7-days branch 2 times, most recently from bd84d51 to 0112dd8 Compare May 13, 2026 14:58
If we are sending a bounce notification to organisation admins, we
want to include a paragraph detailing when we initially contacted the
group admins in the email.

As most of the other content in the email is the same, pass this in as
personalisation rather than using a separate template. We must pass
the whole paragraph as personalisation rather than just the dynamic
content (group name and contacted date), as Notify does not support
optional content with personalisation.
Update the job to accept a parameter for the user role. If the
role is "organisation_admin", get the organisation admin users from
the group to send the bounce notifications to.
We want to send bounce notifications to org admins 7 days after we've
notified the group admins if the bounce has not been resolved.

Schdedule a separate SendBounceNotificationsJob job that will look for
deliveries that bounced 8 days ago, and send notifications to the
organisation admins for the forms they are for.
The new template ID includes additional personalisation for sending to
organisation admins. Once the code changes have been deployed, we can
remove the old template.
Schedule the ScheduleBounceNotificationsJob to run daily at 2:30am
when rails is running in production mode. This job will schedule
SendBounceNotificationsJobs to send notifications for any bounces that
occurred on the previous day to group admins, and for any bounces that
occurred 8 days ago to organisation admins.

2:30am was chosen just to not be the same time as other recurring
jobs.
@stephencdaly stephencdaly force-pushed the send-bounce-notifications-to-org-admins-after-7-days branch 3 times, most recently from 23c4863 to 8e4acf8 Compare May 13, 2026 15:47
@stephencdaly stephencdaly marked this pull request as ready for review May 13, 2026 15:51
@github-actions
Copy link
Copy Markdown
Contributor

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-2089.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
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

@stephencdaly stephencdaly added this pull request to the merge queue May 14, 2026
Merged via the queue into main with commit cc2d218 May 14, 2026
12 checks passed
@stephencdaly stephencdaly deleted the send-bounce-notifications-to-org-admins-after-7-days branch May 14, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants