Add 2 new APIs: listPadsOfAuthor and listAuthorsOfPad

Return all pads that a given author has contributed to (not just
created) and return all authors who has contributed to a given pad.
This commit is contained in:
Marcel Klehr 2012-06-27 18:23:17 +02:00
parent 0bc01feb72
commit 6f9d7a5db7
4 changed files with 132 additions and 2 deletions

View file

@ -47,6 +47,7 @@ exports.createGroupPad = groupManager.createGroupPad;
exports.createAuthor = authorManager.createAuthor;
exports.createAuthorIfNotExistsFor = authorManager.createAuthorIfNotExistsFor;
exports.listPadsOfAuthor = authorManager.listPadsOfAuthor;
/**********************/
/**SESSION FUNCTIONS***/
@ -463,6 +464,26 @@ exports.isPasswordProtected = function(padID, callback)
});
}
/**
listAuthorsOfPad(padID) returns an array of authors who contributed to this pad
Example returns:
{code: 0, message:"ok", data: {authorIDs : ["a.s8oes9dhwrvt0zif", "a.akf8finncvomlqva"]}
{code: 1, message:"padID does not exist", data: null}
*/
exports.listAuthorsOfPad = function(padID, callback)
{
//get the pad
getPadSafe(padID, true, function(err, pad)
{
if(ERR(err, callback)) return;
callback(null, {authorIDs: pad.getAllAuthors()});
});
}
/******************************/
/** INTERNAL HELPER FUNCTIONS */
/******************************/