jitsu
jitsu copied to clipboard
Notifications API
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:
- If a error is occurred (e.g. event hasn't stored into the destination)
- HAS_ERRORS -> OK:
- if there is no errors and there are success events ~5-10 minutes.
- OK -> HAS_ERRORS:
-
[ ] 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.startandendparameters 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:
notifications:project#$PROJECT_ID:queue- sorted set of ids by timestampnotifications:project#$PROJECT_ID:objects- hashset where hash is a notification ID and value is a notification JSON string.