Skip to main content
Question

Get User Groups for a Group Manager

  • 13 December 2019
  • 1 reply
  • 759 views

Is there an API to pull in extensions only that a manager has authorization over? This is in regards to User Groups (Users > User Groups in the Admin Portal) I'm looking to pull in a Group Manager's group and then display all the extensions in the group to allow viewing and modifying their DND status.

I had incorrectly assumed that when pulling the list of extensions, that a manager would only see the users' they manage, but it winds up pulling all extensions from our 1000's of users. I don't see any API relating to User Groups.

You are right about a User group's purpose. But any user/extension can see other's user/extension presence status. So does the group manager! That's why when you send a GET request to "account/~/presence", you will see the entire company's user presence status.

The privilege of a group manager is to update/modify a presence status of its group members without the need of being a super admin.

So in your case, you have to keep track of a list of a group's members, then let the group manager to read only those members and modify their presence status as you need. You can do something like this in Node JS:

var members = ["120", "121", "122"]
function read_user_presence(){
platform.get('/account/~/presence', {
sipData: true
})
.then(function (resp) {
var jsonObj = resp.json()
for (var record of resp.json().records){
const member = (element) => element === record.extension.extensionNumber;
if (members.some(member)){
console.log(JSON.stringify(record))
console.log("=======")
// check a member's status then modify it accordingly
update_user_presence(record.extension.id)
}
}
});
}

function update_user_presence(id){
platform.put('/account/~/extension/' + id + '/presence', {
dndStatus: "DoNotAcceptAnyCalls"
})
.then(function (resp) {
var jsonObj = resp.json()
console.log(jsonObj)
});
}



Reply