Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

This document will help us to achieve the implementation of the notification feature for any specific activity on groups workflow.

Background:

As per the ticket https://project-sunbird.atlassian.net/browse/SB-24361, we are trying to notify the users when there is some action happened in groups workflow.

As discussed with the UP team, we can use the existing the feed APIs to

  1. Notify the users of some actions made in the group scenario.

  2. Mark any notification read

Trigger a notification:

curl --location --request POST 'https://dev.sunbirded.org/api/user/feed/v1/create' \
--header 'Authorization: Bearer <Bearer Key>' \
--header 'x-authenticated-user-token: <user-token>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "request": {
    "userId": "e79ee6a4-d79c-4236-9e05-f754010932d6",
    "category": "group-feed",
    "priority": 1,
    "data": {
      "groupId": "c59cca34-c574-49ad-953b-c1cfc7ad50a3", 
      "message":"You are added to a group. Click here to explore", // this should be a dynamic message
      "activityId": "" // this should be added when we add activity to a group
    }
  }
}'

Response:

{
    "id": "api.user.feed.create",
    "ver": "v1",
    "ts": "2021-05-07 06:08:30:954+0000",
    "params": {
        "resmsgid": null,
        "msgid": "9238f58b985ff0903692475346dc2cee",
        "err": null,
        "status": "success",
        "errmsg": null
    },
    "responseCode": "OK",
    "result": {
        "response": "SUCCESS"
    }
}

Read a notification:

curl --location --request GET 'https://dev.sunbirded.org/api/user/v1/feed/e79ee6a4-d79c-4236-9e05-f754010932d6' \
--header 'Authorization: Bearer <auth-token>' \
--header 'x-authenticated-user-token: <user-token of the given user>' \
--header 'Content-Type: application/json'

Response:

{
    "id": "api.user.feed.e79ee6a4-d79c-4236-9e05-f754010932d6",
    "ver": "v1",
    "ts": "2021-05-07 06:32:49:561+0000",
    "params": {
        "resmsgid": null,
        "msgid": "be4d91699dd609f36677eee9c9b57d3b",
        "err": null,
        "status": "success",
        "errmsg": null
    },
    "responseCode": "OK",
    "result": {
        "response": {
            "userFeed": [
                {
                    "id": "1181f2c1-e944-473b-8b87-b9513087347b",
                    "userId": "e79ee6a4-d79c-4236-9e05-f754010932d6",
                    "category": "group-feed",
                    "priority": 1,
                    "createdBy": "8454cb21-3ce9-4e30-85b5-fade097880d8",
                    "status": "unread",
                    "data": {
                        "groupId": "c59cca34-c574-49ad-953b-c1cfc7ad50a3",
                        "message": "You are added to a group. Click here to explore",
                        "activityId": ""
                    },
                    "createdOn": 1620369023727
                }
            ]
        }
    }
}

Mark notification as read:

To make a notification as read, we have two options here.

  1. We can make the update/feed API call to make a particular feed as read.

  2. Delete a particular feed once it is read.

Update feed:
curl --location --request POST 'https://dev.sunbirded.org/api/user/feed/v1/update' \
--header 'Authorization: Bearer <auth-token>' \
--header 'x-authenticated-user-token: <user-token>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "request": {
    "userId": "a10d5216-6b96-404c-8d1c-cc1f720d910a",
    "category": "group-feed",
    "feedId": "22ba004f-3b07-429e-bb9a-0bd3dfb21d2b",
    "status": "read",
  }
}'
Delete feed:
curl --location --request POST 'https://dev.sunbirded.org/api/user/feed/v1/delete' \
--header 'Authorization: Bearer <auth-token>' \
--header 'x-authenticated-user-token: <user token of the given user>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "request": {
    "userId": "e79ee6a4-d79c-4236-9e05-f754010932d6",
    "category": "group-feed",
    "feedId": "12a13052-6e64-431d-b622-185bc0aca33f"
  }
}'
Response:
{
    "id": "api.user.feed.update/delete",
    "ver": "v1",
    "ts": "2021-05-07 06:54:22:856+0000",
    "params": {
        "resmsgid": null,
        "msgid": "814e2ade1965ede9dce2fe6fac2bc61d",
        "err": null,
        "status": "success",
        "errmsg": null
    },
    "responseCode": "OK",
    "result": {
        "response": "SUCCESS"
    }
}
  • No labels