Skip to content

Node.js based forum software built for the modern web

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

Julian Lama5832624d741
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,