From a5832624d741b4805a9fc856376ec922d18c2211 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 17 Apr 2015 14:38:01 -0400 Subject: [PATCH] added optional parameter to define timestamp when sending a chat message, for use in write API --- src/messaging.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/messaging.js b/src/messaging.js index eccff45cff..d80cf4a78c 100644 --- a/src/messaging.js +++ b/src/messaging.js @@ -27,14 +27,20 @@ var db = require('./database'), return [fromuid, touid].sort(); } - Messaging.addMessage = function(fromuid, touid, content, callback) { + Messaging.addMessage = function(fromuid, touid, content, timestamp, callback) { var uids = sortUids(fromuid, touid); + if (typeof timestamp === 'function') { + callback = timestamp; + timestamp = Date.now(); + } else { + timestamp = timestamp || Date.now(); + } + db.incrObjectField('global', 'nextMid', function(err, mid) { if (err) { return callback(err); } - var timestamp = Date.now(); var message = { content: content, timestamp: timestamp,