added optional parameter to define timestamp when sending a chat message, for use in write API

v1.18.x
Julian Lam 10 years ago
parent 5587233e78
commit a5832624d7

@ -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,

Loading…
Cancel
Save