Skip to content

Resolve "Allow a single notification_log object to have multiple recipients"

Zac Pullar-Strecker requested to merge 38-multiple-recipients into master

Depends on !71 (merged)

Potential Regressions

  • It is now impossible to distinguish between notifications that never had .send() called and notifications that did, but there were no contact methods to send to. These notifications will show up as 'Not yet sent'.

Changes

Adds a new model NotificationAttempt

A NotificationAttempt is an attempt to send a notification to a particular user.

NotificationAttempt takes over storing the following information from Notification:

  • Contact (and by relationship User)
  • Status (overall status is computed by Notification based on it's attempts)
  • Errors
  • Warnings
  • Method
  • Provider
  • Reply to (replies are to attempts)

Multiple NotificationAttempts will be created if:

  • An attempt fails
  • The notification was sent to multiple users

Changes sending methods to support multiple recipients

The sending methods accept a user to send the notification to. This is a required parameter and is additional to existing options like method and contact.

Delays message body rendering

In order to support localising languages and timestamps the 'body' of a message is not rendered until it is sent to a user, and it is rendered differently for each user. This is currently only used by alerts for timestamps.

Removes to_user_id from Message

Messages are no longer associated with a user until they are sent to a user.

This change is possibly debatable. Currently messages are used for the following:

  • Replies - Replies are to Attempts which have a user associated with them Replies are to notifications, which have no user associated with them.
  • Failed pages - Are sent to multiple users
  • Custom messages - Debatable?
  • Heartbeat messages - Are sent to multiple users
  • Test messages - Are logically to a single user

Does not change Handovers

Handovers have a to_user, and optional from_user associated with them. The same notification object is sent to both users if applicable.

Removes user_id from Alerts

Alerts are no longer associated with a particular user. This allows them to be sent to multiple users in preparation for #1 (closed).

Closes #38 (closed)

Edited by Callum Dickinson

Merge request reports