-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial user notification backend #4164
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4164 +/- ##
==========================================
- Coverage 78.17% 78.13% -0.04%
==========================================
Files 287 292 +5
Lines 13310 13403 +93
Branches 2986 3000 +14
==========================================
+ Hits 10405 10473 +68
- Misses 2905 2930 +25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pulled and tested with curls locally. works as expected.
One suggestion would be to consider the read
field - Is the a possibility of a future where notifications could be "paused", or "forwarded" or something other than read: true/false
? Implementing this now would save a future migration. The original proposal did request a status
field which would cater for such instances?
However, that said, not gonna block this.
One other suggestion, since this is very early days, it might be wise to mark the API as private to avoid any lock in (however unlikely that is at this early stage)
None of the apis I've researched around notifications have multiple states like this. A notification is either read or unread. If we find a need for other states, they can be a new field that is independent of whether the user has 'seen' a notification or not. |
Not going to merge this until I make a bit more progress with #4165 to help validate the assumptions in this PR |
Updated to include the new |
Rewire frontend notifications to backend notifications API
Add notification when user team invite is created
Closes #4158
Description
Implements the backend design for user notifications - as detailed in #4113
Database
New
Notification
model added, including db migration to create the table:External API
GET /api/v1/user/notifications
- returns notifications, most recent first. Uses pagination as per standard designPUT /api/v1/user/notifications/:id
- mark notification readread
-true
/false
DELETE /api/v1/user/notifications/:id
- delete a notificationNot included
The spec in #4113 included bulk end points - I haven't implemented them in this PR as unnecessary for first iteration where we can make individual api requests to update individual notifications
PUT /api/v1/user/notifications
- bulk mark notifications read. Will mark all read by defaultDELETE /api/v1/user/notifications
- bulk deleteRuntime API
A bare bones API is provided to send a notification to a user. Not going to over specify this until work is done to start adding real notifications.
user
- the User to send the notification to (a fullapp.db.models.User
object)type
-string
- the type of notification. This will be one from a well-defined list. How they get defined (and whether we add convenience functions like we have for the auditLog) can be determined as we start adopting it.data
-object
- contextual data needed for the notification. This will get exposed on the API, so must not include raw database ids - only hashids.reference
- (optional)string
- a reference that can be used to clear this notification lateruser
- the User to remove the notification for (a fullapp.db.models.User
object)reference
-string
- the notification reference to removeThe idea behind
reference
is that we can associate the notification with something - such as the hashid of an invitation. When that invitation is processed, we can remove the notification.