Resolve "Allow a single notification_log object to have multiple recipients"
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
NotificationAttempt
Adds a new model 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 NotificationAttempt
s 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.
to_user_id
from Message
Removes 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 toReplies are to notifications, which have no user associated with them.Attempt
s which have a 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
Handover
s
Does not change Handovers have a to_user
, and optional from_user
associated with them. The same notification object is sent to both users if applicable.
user_id
from Alert
s
Removes 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)