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:
Mehmet Ali Elicin 2012-04-04 14:02:08 -07:00
parent cfb58a80a3
commit 3c8674ebde
4 changed files with 130 additions and 3 deletions

View file

@ -82,6 +82,9 @@ Pad.prototype.appendRevision = function appendRevision(aChangeset, author) {
chatHead: this.chatHead,
publicStatus: this.publicStatus,
passwordHash: this.passwordHash});
// set the author to pad
if(author != '')
authorManager.addPad(author, this.id);
};
Pad.prototype.getRevisionChangeset = function getRevisionChangeset(revNum, callback) {
@ -432,6 +435,18 @@ Pad.prototype.remove = function remove(callback) {
db.remove("pad:"+padID+":revs:"+i);
}
callback();
},
//remove pad from all authors who contributed
function(callback)
{
var authorIDs = _this.getAllAuthors();
authorIDs.forEach(function (authorID)
{
authorManager.removePad(authorID, padID);
});
callback();
}
], callback);