summaryrefslogtreecommitdiff
path: root/src/node/db
diff options
context:
space:
mode:
authorMike DeRosa <derosm2@gmail.com>2015-02-09 00:18:12 -0500
committerMike DeRosa <derosm2@gmail.com>2015-02-09 00:18:12 -0500
commit4c6bd37286ca2d2639fb0b379108a8a5f4ee4ea0 (patch)
tree31422b381bf942a011ffaa2832ece5017aee8e8e /src/node/db
parent5c31d1f52834d6b6f5641d31ea026e57b4615b4a (diff)
downloadetherpad-lite-4c6bd37286ca2d2639fb0b379108a8a5f4ee4ea0.zip
Adding api call for appending a chat message.
Diffstat (limited to 'src/node/db')
-rw-r--r--src/node/db/API.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/node/db/API.js b/src/node/db/API.js
index 81dedcfe..75e4986b 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 */
/*****************/