Add in padUsers HTTP API call

I needed the list of users this time, so I got it. There are docs
and everything.
This commit is contained in:
Mark Holmquist 2012-08-17 11:46:34 -07:00
parent 9b1673c60f
commit f9469ef256
4 changed files with 29 additions and 0 deletions

View file

@ -48,6 +48,7 @@ exports.createGroupPad = groupManager.createGroupPad;
exports.createAuthor = authorManager.createAuthor;
exports.createAuthorIfNotExistsFor = authorManager.createAuthorIfNotExistsFor;
exports.listPadsOfAuthor = authorManager.listPadsOfAuthor;
exports.padUsers = padMessageHandler.padUsers;
exports.padUsersCount = padMessageHandler.padUsersCount;
/**********************/

View file

@ -67,6 +67,7 @@ var functions = {
"isPasswordProtected" : ["padID"],
"listAuthorsOfPad" : ["padID"],
"padUsersCount" : ["padID"],
"padUsers" : ["padID"],
"sendClientsMessage" : ["padID", "msg"]
};

View file

@ -1410,3 +1410,26 @@ exports.padUsersCount = function (padID, callback) {
callback(null, {padUsersCount: pad2sessions[padID].length});
}
}
/**
* Get the list of users in a pad
*/
exports.padUsers = function (padID, callback) {
if (!pad2sessions[padID] || typeof pad2sessions[padID] != typeof []) {
callback(null, {padUsers: []});
} else {
var authors = [];
for ( var ix in sessioninfos ) {
if ( sessioninfos[ix].padId !== padID ) {
continue;
}
var aid = sessioninfos[ix].author;
authorManager.getAuthor( aid, function ( err, author ) {
authors.push( author );
if ( authors.length === pad2sessions[padID].length ) {
callback(null, {padUsers: authors});
}
} );
}
}
}