summaryrefslogtreecommitdiff
path: root/src/node/db/API.js
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2012-06-27 18:23:17 +0200
committerMarcel Klehr <mklehr@gmx.net>2012-06-27 18:23:17 +0200
commit6f9d7a5db79076747584ebd289bf380b2bb95038 (patch)
treec0703fee5c77bcc445e14a060bd5b48cd68e13ea /src/node/db/API.js
parent0bc01feb72f116c95faafd78df2eb87b6fae3143 (diff)
downloadetherpad-lite-6f9d7a5db79076747584ebd289bf380b2bb95038.zip
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.
Diffstat (limited to 'src/node/db/API.js')
-rw-r--r--src/node/db/API.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/node/db/API.js b/src/node/db/API.js
index 37fd3f16..c766c80a 100644
--- a/src/node/db/API.js
+++ b/src/node/db/API.js
@@ -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 */
/******************************/