Node.js based forum software built for the modern web
changing function signature for messaging.getMessages
psychobunnye0cfc117c7bd
diff --git a/src/controllers/accounts.js b/src/controllers/accounts.jsindex cafcabafcb..5023d24d55 100644--- a/src/controllers/accounts.js+++ b/src/controllers/accounts.js@@ -623,7 +623,12 @@ accountsController.getChats = function(req, res, next) {async.parallel({toUser: async.apply(user.getUserFields, toUid, ['uid', 'username']),- messages: async.apply(messaging.getMessages, req.user.uid, toUid, 'recent', false),+ messages: async.apply(messaging.getMessages, {+ fromuid: req.user.uid,+ touid: toUid,+ since: 'recent',+ isNew: false+ }),allowed: async.apply(messaging.canMessage, req.user.uid, toUid)}, next);}diff --git a/src/messaging.js b/src/messaging.jsindex bb1ce85182..fbb61199ca 100644--- a/src/messaging.js+++ b/src/messaging.js@@ -96,11 +96,16 @@ var db = require('./database'),});};- Messaging.getMessages = function(fromuid, touid, since, isNew, callback) {- var uids = sortUids(fromuid, touid);+ Messaging.getMessages = function(params, callback) {+ var fromuid = params.fromuid,+ touid = params.touid,+ since = params.since,+ isNew = params.isNew,+ count = params.count || parseInt(meta.config.chatMessageInboxSize, 10) || 250;++ var uids = sortUids(fromuid, touid),+ min = Date.now() - (terms[since] || terms.day);- var count = parseInt(meta.config.chatMessageInboxSize, 10) || 250;- var min = Date.now() - (terms[since] || terms.day);if (since === 'recent') {count = 49;min = 0;@@ -166,7 +171,7 @@ var db = require('./database'),message.newSet = true;} else if (index > 0 && message.fromuid !== messages[index-1].fromuid) {// If the previous message was from the other person, this is also a new set- message.newSet = true+ message.newSet = true;}return message;diff --git a/src/socket.io/modules.js b/src/socket.io/modules.jsindex 95380a4b49..9ceecf1cb8 100644--- a/src/socket.io/modules.js+++ b/src/socket.io/modules.js@@ -22,7 +22,12 @@ SocketModules.chats.get = function(socket, data, callback) {return callback(new Error('[[error:invalid-data]]'));}- Messaging.getMessages(socket.uid, data.touid, data.since, false, callback);+ Messaging.getMessages({+ fromuid: socket.uid,+ touid: data.touid,+ since: data.since,+ isNew: false+ }, callback);};SocketModules.chats.send = function(socket, data, callback) {