Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #SB-27440 feat: Call notification service api call on each act… #43

Open
wants to merge 3 commits into
base: release-4.2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const privileges = require.main.require('./src/privileges');
const _ = require('lodash');
const copyPrivilages = '/api/privileges/v2/copy'
const getUids = '/api/forum/v2/uids';
const sbUserIds = '/api/forum/v2/sunbird/uids';
const addUserIntoGroup = '/api/forum/v3/group/membership';
const groupsPriveleges = '/api/forum/v3/category/:cid/privileges';
const oidcPlugin = require.main.require('./node_modules/nodebb-plugin-sunbird-oidc/library.js');
Expand Down Expand Up @@ -1341,6 +1342,23 @@ function healthCheck (req, res) {
}
}
}
async function getSBUserIds (req, res) {
const data = { ...req.body.request };
const requiredParams = jsonConstants.requiredParams[req.route.path];
const isPayloadCorrect = await util.checkRequiredParameters(req, res, requiredParams, data);
if (isPayloadCorrect) {
let sbuids = [];
const uids = data.uids;
for(let i=0; i< uids.length; i++) {
const userObj = await Users.getUserFields(uids[i], ['sunbird-oidcId', 'username']);
sbuids.push(userObj);
if(i === (uids.length - 1)) {
const responseObj = await util.responseData(req, res, sbuids, null);
res.send(responseObj);
}
}
}
}

Plugin.load = function (params, callback) {
var router = params.router
Expand All @@ -1359,7 +1377,7 @@ Plugin.load = function (params, callback) {
router.post(listOfGroupUsers, getContextUserGroups);
router.post(groupsPriveleges, getContextGroupPriveleges);
router.post(updateUserProfile, updateUserProfileData);

router.post(sbUserIds, getSBUserIds);
router.get('/api/forum/test/user/:userslug', getUserDetails);

router.get('/api/forum/health', healthCheck);
Expand Down
6 changes: 6 additions & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ module.exports = {
name: 'sbIdentifier',
type: 'any'
}
],
'/api/forum/v2/sunbird/uids': [
{
name: 'uids',
type: 'array'
}
]
},
forumStrings: {
Expand Down