diff options
author | Peter 'Pita' Martischka <petermartischka@googlemail.com> | 2011-08-09 12:09:04 +0100 |
---|---|---|
committer | Peter 'Pita' Martischka <petermartischka@googlemail.com> | 2011-08-09 12:09:04 +0100 |
commit | e336b4f940d129e7b50e965ccb7f42a2fae2e0f6 (patch) | |
tree | 921fa47c6ea799278f02b77cdf803cf22f26b678 | |
parent | e6ba60bddcd3d4e7201c949ad5a41ac9e82f999a (diff) | |
download | etherpad-lite-e336b4f940d129e7b50e965ccb7f42a2fae2e0f6.zip |
added create Author
-rw-r--r-- | node/db/API.js | 6 | ||||
-rw-r--r-- | node/db/AuthorManager.js | 10 | ||||
-rw-r--r-- | node/handler/APIHandler.js | 2 |
3 files changed, 8 insertions, 10 deletions
diff --git a/node/db/API.js b/node/db/API.js index 37ed330b..e3690671 100644 --- a/node/db/API.js +++ b/node/db/API.js @@ -22,6 +22,7 @@ var padManager = require("./PadManager"); var padMessageHandler = require("../handler/PadMessageHandler"); var readOnlyManager = require("./ReadOnlyManager"); var groupManager = require("./GroupManager"); +var authorManager = require("./AuthorManager"); var async = require("async"); /**********************/ @@ -92,10 +93,7 @@ Example returns: {code: 0, message:"ok", data: {authorID: 5}} */ -exports.createAuthor = function(name, callback) -{ - -} +exports.createAuthor = authorManager.createAuthor; /** getMappedAuthor4(authorMapper [, name]) this functions helps you to map your application author ids to etherpad lite author ids diff --git a/node/db/AuthorManager.js b/node/db/AuthorManager.js index a0187ed7..a6fc3728 100644 --- a/node/db/AuthorManager.js +++ b/node/db/AuthorManager.js @@ -47,7 +47,7 @@ exports.getAuthor4Token = function (token, callback) //there is no author with this token, so create one if(author == null) { - createAuthor(null, function(err, _author) + exports.createAuthor(null, function(err, _author) { //error? if(err) @@ -56,7 +56,7 @@ exports.getAuthor4Token = function (token, callback) return; } - author = _author; + author = _author.authorID; //create the token2author relation db.set("token2author:" + token, author); @@ -80,9 +80,9 @@ exports.getAuthor4Token = function (token, callback) /** * Internal function that creates the database entry for an author - * @param {String} token The token + * @param {String} name The name of the author */ -function createAuthor (name, callback) +exports.createAuthor = function(name, callback) { //create the new author name var author = "g." + _randomString(16); @@ -93,7 +93,7 @@ function createAuthor (name, callback) //set the global author db entry db.set("globalAuthor:" + author, authorObj); - callback(null, author); + callback(null, {authorID: author}); } /** diff --git a/node/handler/APIHandler.js b/node/handler/APIHandler.js index 2d7d9ae6..0c12a271 100644 --- a/node/handler/APIHandler.js +++ b/node/handler/APIHandler.js @@ -41,7 +41,7 @@ var functions = { "listPads" : ["groupID"], "createPad" : ["padID", "text"], "createGroupPad" : ["groupID", "padName", "text"], -// "createAuthor" : ["name"], + "createAuthor" : ["name"], // "getMappedAuthor4" : ["authorMapper" , "name"], // "createSession" : ["groupID", "authorID", "validUntil"], // "deleteSession" : ["sessionID"], |