Discussion forum notifications

 

Introduction

This document describes the key design problem statement and probable solutions for
discussion forum notifications https://project-sunbird.atlassian.net/browse/SB-25091 .

Problem Statement

Sending notification to user for each action performed in discussion forum.

Key designs solutions

  • Labels

  • How to get sunbird identifiers in discussion forum middleware

  • How to call notification feed api from discussion forum middleware

  • How to make notification configurable

  • what data need to dump in additional info.

    • Context info.

    • Category info.

    • Topic info.

    • Post info

Example:

Case 1: When someone adds a reply to the post(topic) created by him/her User1  replied to your topic ${user} ${action} to your ${type} Case2: When someone adds a reply to the comment/reply added by him/her User1  replied to your post ${user} ${action} to your ${type} Case3: When someone upvotes the post(topic) created by him/her User1  upvoted to your topic ${user} ${action} to your ${type} Case4: When someone upvotes the reply/comment added by him/her User1  upvoted to your post ${user} ${action} to your ${type} Case5: When someone downvotes the post(topic) created by him/her User1  downvoted to your topic ${user} ${action} to your ${type} Case6: When someone downvotes the reply/comment added by him/her User1  downvoted to your post ${user} ${action} to your ${type}

 

Additional INFO:

"additionalInfo": { "context": { "type": "group/course/batch", "identifier": "groupID/courseID/batchID", "cid": "categoryID" }, "topic": { "tid": "topicID", "title": "topicTitle", "slug": "topicSlug" }, "category": { "cid": "CID", "title": "categoryTitle", "slug": "categorySlug" }, "post": { "pid": "postID", "title": "postTitle", "slug": "postSlug" } }

 

Labels

Action

Message

Params

When someone adds a reply to the post(topic) created by him/her 

User1  replied to your topic

${user} ${action} to your ${type}

When someone adds a reply to the comment/reply added by him/her

User1  replied to your post

${user} ${action} to your ${type}

When someone upvotes the post(topic) created by him/her 

User1  upvoted to your topic

${user} ${action} to your ${type}

When someone upvotes the reply/comment added by him/her

User1  upvoted to your post

${user} ${action} to your ${type}

When someone downvotes the post(topic) created by him/her

User1  downvoted to your topic

${user} ${action} to your ${type}

When someone downvotes the reply/comment added by him/her 

User1  downvoted to your post

${user} ${action} to your ${type}

Template IDS

Action type’s

Data

Schema

replied

member-replied

{

“title“: “${param1} ${param2} to your ${param3}“

}

{

"$schema": "#/definition/params",

"title": "params context",

"description": "properties Data",

"type": "object",

"properties": {

"param1": {

"description": "property 1 value",

"type": "string"

},

"param2": {

"description": "property 2 value",

"type": "string"

},

"param3": {

"description": "property 3 value",

"type": "string"

}

},

"required": [

"param1",

"param2",

“param3“

]

}

voted

member-voted

{

“title“: “${param1} ${param2} to your ${param3}“

}

{

"$schema": "#/definition/params",

"title": "params context",

"description": "properties Data",

"type": "object",

"properties": {

"param1": {

"description": "property 1 value",

"type": "string"

},

"param2": {

"description": "property 2 value",

"type": "string"

},

"param3": {

"description": "property 3 value",

"type": "string"

}

},

"required": [

"param1",

"param2",

"param3"

]

}

 

Solution:

Get sunbird identifiers in discussion forum middleware

For this we have both fromUID and creator uid, can with this uids we can get the respective sunbird ids by calling this api

Path: /api/forum/v2/uids

Request:

curl --location --request POST 'https://preprod.ntp.net.in/discussions/api/forum/v2/uids' \ --header 'Content-Type: application/json' \ --data-raw '{ "request": { "sbIdentifiers": [ "7a78a1f2-0a29-4c1b-9898-061d7314d030", "efd862be-b275-4209-8a31-2f2e25874f1b" ] } }'

Response:

 

How to call notification feed api from discussion forum middleware

 

How to make notification configurable

  • Create new env variable in DMW

 

Prepare payload for notification api

Payload

 

Example

 

 

User Actions

  1. Topic reply

Req url : {host}/discussion/v2/topic/:tid

Curl:

Response:

2. Vote to topic or reply

Req url: {host}/discussion/v2/posts/:pid/vote

Curl:

Response: