possible fix for #1909

v1.18.x
barisusakli 11 years ago
parent 68cf064b1e
commit 1a68fe5a26

@ -4,17 +4,16 @@ module.exports = function(db, module) {
var helpers = module.helpers.mongo;
module.listPrepend = function(key, value, callback) {
callback = callback || function() {};
value = helpers.valueToString(value);
module.isObjectField(key, 'array', function(err, exists) {
if(err) {
if(typeof callback === 'function') {
return callback(err);
}
if (err) {
return callback(err);
}
if(exists) {
db.collection('objects').update({_key:key}, {'$set': {'array.-1': value}}, {upsert:true, w:1 }, helpers.done(callback));
if (exists) {
db.collection('objects').update({_key:key}, {$push: {array: {$each: [value], $position: 0}}}, {upsert:true, w:1 }, callback);
} else {
module.listAppend(key, value, callback);
}

@ -87,7 +87,7 @@ var db = require('./database'),
Messaging.getMessages = function(fromuid, touid, isNew, callback) {
var uids = sortUids(fromuid, touid);
db.getSortedSetRange('messages:uid:' + uids[0] + ':to:' + uids[1], -((meta.config.chatMessagesToDisplay || 50) - 1), -1, function(err, mids) {
db.getSortedSetRevRange('messages:uid:' + uids[0] + ':to:' + uids[1], 0, (meta.config.chatMessagesToDisplay || 50) - 1, function(err, mids) {
if (err) {
return callback(err);
}
@ -96,6 +96,8 @@ var db = require('./database'),
return callback(null, []);
}
mids.reverse();
getMessages(mids, fromuid, touid, isNew, callback);
});

Loading…
Cancel
Save