diff options
author | John McLear <john@mclear.co.uk> | 2015-04-01 13:32:07 +0100 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2015-04-01 13:32:07 +0100 |
commit | c705a058fbf7764c6da7625229e051f3aa70fb2b (patch) | |
tree | 4ac21956a1c509d35982113b2c5d1b80c08ae2a6 /src/node/db | |
parent | 70fdc7dcd7278dfe6f5c0b050134c0eae106e028 (diff) | |
parent | 4c6bd37286ca2d2639fb0b379108a8a5f4ee4ea0 (diff) | |
download | etherpad-lite-c705a058fbf7764c6da7625229e051f3aa70fb2b.zip |
Merge branch 'feature/append-chat-api' of github.com:derosm2/etherpad-lite into append-chat-api
Diffstat (limited to 'src/node/db')
-rw-r--r-- | src/node/db/API.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/node/db/API.js b/src/node/db/API.js index 69a380c7..77546bd2 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -494,6 +494,33 @@ exports.getChatHistory = function(padID, start, end, callback) }); } +/** +appendChatMessage(padID, text, userID, time), creates a chat message for the pad id + +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) +{ + //text is required + if(typeof text != "string") + { + callback(new customError("text is no string","apierror")); + return; + } + + //get the pad + getPadSafe(padID, true, function(err, pad) + { + if(ERR(err, callback)) return; + + pad.appendChatMessage(text, userID, parseInt(time)); + callback(); + }); +} + /*****************/ /**PAD FUNCTIONS */ /*****************/ |