diff options
author | Stefan <mu.stefan@googlemail.com> | 2015-08-15 22:05:31 +0200 |
---|---|---|
committer | Stefan <mu.stefan@googlemail.com> | 2015-08-15 22:05:31 +0200 |
commit | 94cb743ca8a772edde7383b0b0567eb8104817f8 (patch) | |
tree | 334894f165c8859915f4ead198c6d35a8f9b2586 /src/node/db | |
parent | 02c022aab14f9087e22cebd4123336935cc089d8 (diff) | |
download | etherpad-lite-94cb743ca8a772edde7383b0b0567eb8104817f8.zip |
Fix API call appendChatMessage to send new message to all connected clients
Diffstat (limited to 'src/node/db')
-rw-r--r-- | src/node/db/API.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/node/db/API.js b/src/node/db/API.js index 97d5162d..7b5a7b37 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -510,15 +510,19 @@ exports.appendChatMessage = function(padID, text, authorID, time, callback) callback(new customError("text is no string","apierror")); return; } - - //get the pad - getPadSafe(padID, true, function(err, pad) + + // if time is not an integer value + if(time === undefined || !is_int(time)) { - if(ERR(err, callback)) return; - - pad.appendChatMessage(text, authorID, parseInt(time)); - callback(); - }); + // set time to current timestamp + time = new Date().getTime(); + } + + var padMessage = require("ep_etherpad-lite/node/handler/PadMessageHandler.js"); + // save chat message to database and send message to all connected clients + padMessage.sendChatMessageToPadClients(parseInt(time), authorID, text, padID); + + callback(); } /*****************/ |