Skip to content

[Brainstorm] Design for web notifications

Ashwin Date edited this page Oct 4, 2017 · 1 revision

Web notifications allow creating broadcast messages to be delivered to users. The implementation has a 'pull' based approach. The browser will call the notification service to find out if there is any unseen notifications for the authenticated user. The API returns these, and it's upto the application to display them to the user.

The service has an API to mark a notification as 'seen', which ensures that the user will not see the same notification again.

Sticky notifications are also supported. These cannot me 'marked as read'.

Note that there may be multiple unseen notifications for a user, so the application will need to address displaying these.

Entities

Notification

The notification entity is used to store notifications created. The following attributes are available

  • notification_id (Unique identifier)
  • text (The text of the notification)
  • expires_on (Expiry date for the notification)
  • is_sticky (Is this a sticky notification)
  • is_enabled (Used to temporarily disable the notification)
  • context (Context and context id are used to create 'notification buckets'. This will allow the service to be used by any consumer
  • context_id
  • created_on
  • created_by
  • updated_on
  • updated_by

Notification Reads

Once a user marks a notification as read, a notification read record is created. The attributes are

  • notification_id
  • user_id
  • received_on (Will be auto-updated when this notification shows up in the /notifications/get API)
  • read_on (Updated when the /notifications/read API is called for this notification)

APIs

Create notification

POST /notification/create

Request Params

  • text (mandatory)
  • expired_on
  • is_sticky
  • is_enabled
  • context
  • context_id

The creator is automatically set from the authentication information of the API caller.

Response

  • success / failure
  • notification_id

Get notifications

GET /notification/get

Response

The response is an array of Notification objects for the user. These are all the unseen notifications for the user who is making the API call.

Mark notification as read

POST /notification/read/<notification_id>

The creator is automatically set from the authentication information of the API caller.

Response

  • success / failure