tests and fix up sloppy code by original author

This commit is contained in:
John McLear 2015-04-01 13:52:56 +01:00
parent c705a058fb
commit 32a09ff461
3 changed files with 120 additions and 7 deletions

View file

@ -432,8 +432,8 @@ getChatHistory(padId, start, end), returns a part of or the whole chat-history o
Example returns:
{"code":0,"message":"ok","data":{"messages":[{"text":"foo","userId":"a.foo","time":1359199533759,"userName":"test"},
{"text":"bar","userId":"a.foo","time":1359199534622,"userName":"test"}]}}
{"code":0,"message":"ok","data":{"messages":[{"text":"foo","authorID":"a.foo","time":1359199533759,"userName":"test"},
{"text":"bar","authorID":"a.foo","time":1359199534622,"userName":"test"}]}}
{code: 1, message:"start is higher or equal to the current chatHead", data: null}
@ -495,14 +495,14 @@ exports.getChatHistory = function(padID, start, end, callback)
}
/**
appendChatMessage(padID, text, userID, time), creates a chat message for the pad id
appendChatMessage(padID, text, authorID, time), creates a chat message for the pad id, time is a timestamp
Example returns:
{code: 0, message:"ok", data: null
{code: 1, message:"padID does not exist", data: null}
*/
exports.appendChatMessage = function(padID, text, userID, time, callback)
exports.appendChatMessage = function(padID, text, authorID, time, callback)
{
//text is required
if(typeof text != "string")
@ -516,7 +516,7 @@ exports.appendChatMessage = function(padID, text, userID, time, callback)
{
if(ERR(err, callback)) return;
pad.appendChatMessage(text, userID, parseInt(time));
pad.appendChatMessage(text, authorID, parseInt(time));
callback();
});
}

View file

@ -438,13 +438,13 @@ var version =
, "getChatHistory" : ["padID"]
, "getChatHistory" : ["padID", "start", "end"]
, "getChatHead" : ["padID"]
, "appendChatMessage" : ["padID", "text", "userID", "time"]
, "appendChatMessage" : ["padID", "text", "authorID", "time"]
, "restoreRevision" : ["padID", "rev"]
}
};
// set the latest available API version here
exports.latestApiVersion = '1.2.11';
exports.latestApiVersion = '1.2.12';
// exports the versions so it can be used by the new Swagger endpoint
exports.version = version;