mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 12:36:02 +01:00
added optional parameter to define timestamp when sending a chat message, for use in write API
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user