added create Author

This commit is contained in:
Peter 'Pita' Martischka 2011-08-09 12:09:04 +01:00
parent e6ba60bddc
commit e336b4f940
3 changed files with 8 additions and 10 deletions

View File

@ -22,6 +22,7 @@ var padManager = require("./PadManager");
var padMessageHandler = require("../handler/PadMessageHandler"); var padMessageHandler = require("../handler/PadMessageHandler");
var readOnlyManager = require("./ReadOnlyManager"); var readOnlyManager = require("./ReadOnlyManager");
var groupManager = require("./GroupManager"); var groupManager = require("./GroupManager");
var authorManager = require("./AuthorManager");
var async = require("async"); var async = require("async");
/**********************/ /**********************/
@ -92,10 +93,7 @@ Example returns:
{code: 0, message:"ok", data: {authorID: 5}} {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 getMappedAuthor4(authorMapper [, name]) this functions helps you to map your application author ids to etherpad lite author ids

View File

@ -47,7 +47,7 @@ exports.getAuthor4Token = function (token, callback)
//there is no author with this token, so create one //there is no author with this token, so create one
if(author == null) if(author == null)
{ {
createAuthor(null, function(err, _author) exports.createAuthor(null, function(err, _author)
{ {
//error? //error?
if(err) if(err)
@ -56,7 +56,7 @@ exports.getAuthor4Token = function (token, callback)
return; return;
} }
author = _author; author = _author.authorID;
//create the token2author relation //create the token2author relation
db.set("token2author:" + token, author); db.set("token2author:" + token, author);
@ -80,9 +80,9 @@ exports.getAuthor4Token = function (token, callback)
/** /**
* Internal function that creates the database entry for an author * 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 //create the new author name
var author = "g." + _randomString(16); var author = "g." + _randomString(16);
@ -93,7 +93,7 @@ function createAuthor (name, callback)
//set the global author db entry //set the global author db entry
db.set("globalAuthor:" + author, authorObj); db.set("globalAuthor:" + author, authorObj);
callback(null, author); callback(null, {authorID: author});
} }
/** /**

View File

@ -41,7 +41,7 @@ var functions = {
"listPads" : ["groupID"], "listPads" : ["groupID"],
"createPad" : ["padID", "text"], "createPad" : ["padID", "text"],
"createGroupPad" : ["groupID", "padName", "text"], "createGroupPad" : ["groupID", "padName", "text"],
// "createAuthor" : ["name"], "createAuthor" : ["name"],
// "getMappedAuthor4" : ["authorMapper" , "name"], // "getMappedAuthor4" : ["authorMapper" , "name"],
// "createSession" : ["groupID", "authorID", "validUntil"], // "createSession" : ["groupID", "authorID", "validUntil"],
// "deleteSession" : ["sessionID"], // "deleteSession" : ["sessionID"],