jitsu icon indicating copy to clipboard operation
jitsu copied to clipboard

Notifications API

Open xtreding opened this issue 4 years ago • 0 comments

Problem

In the continuation of #399 backend should have a Notifications API for saving/getting/deleting notifications and UI should use the API. Also, not linked sources notification should be stored via API (not in local storage).

Solution

  • [ ] on the backend side each destination should have a state that is (OK , HAS_ERRORS). State is changed:

    • OK -> HAS_ERRORS:
      1. If a error is occurred (e.g. event hasn't stored into the destination)
    • HAS_ERRORS -> OK:
      1. if there is no errors and there are success events ~5-10 minutes.
  • [ ] get notifications: GET /proxy/api/v1/notifications?project_id=$PROJECT_ID&start=2021-06-16T16:08:12.732Z&end=2021-06-17T16:08:12.732Z. start and end parameters are optional. Default values: start = unix epoch start, end = now. The response will contain notifications sorted by DateTime list (desc): HTTP 200 OK

{
  "notifications": [
    {
      "id": "b146f32e-3900-4201-b1f6-21a9049fb06a",
      "type": "not_linked_sources",
      "message": "Text body of the notification",
      ...
      "destination_id": "id of destination"
    },
    {
      "id": "da8bf207-62df-411d-92c7-d205234a2691",
      "type": "not_linked_sources",
      "message": "Text body of the notification",
      ...
      "destination_id": "id of destination"
    }
  ]
}

Notifications should be saved in Redis with the following keys:

  1. notifications:project#$PROJECT_ID:queue - sorted set of ids by timestamp
  2. notifications:project#$PROJECT_ID:objects - hashset where hash is a notification ID and value is a notification JSON string.

xtreding avatar Jun 17 '21 16:06 xtreding