mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
Improved chat message managing
This commit is contained in:
parent
ec0d9c9452
commit
783203b865
1 changed files with 18 additions and 6 deletions
|
@ -214,7 +214,7 @@ Class('Pad', {
|
||||||
db.setSub("pad:"+this.id, ["chatHead"], this.chatHead);
|
db.setSub("pad:"+this.id, ["chatHead"], this.chatHead);
|
||||||
},
|
},
|
||||||
|
|
||||||
getChatMessage: function(entryNum, withName, callback)
|
getChatMessage: function(entryNum, callback)
|
||||||
{
|
{
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var entry;
|
var entry;
|
||||||
|
@ -232,8 +232,8 @@ Class('Pad', {
|
||||||
//add the authorName
|
//add the authorName
|
||||||
function(callback)
|
function(callback)
|
||||||
{
|
{
|
||||||
//skip if we don't need the authorName
|
//this chat message doesn't exist, return null
|
||||||
if(!withName)
|
if(entry == null)
|
||||||
{
|
{
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
|
@ -287,14 +287,26 @@ Class('Pad', {
|
||||||
var entries = [];
|
var entries = [];
|
||||||
async.forEach(neededEntries, function(entryObject, callback)
|
async.forEach(neededEntries, function(entryObject, callback)
|
||||||
{
|
{
|
||||||
_this.getChatMessage(entryObject.entryNum, true, function(err, entry)
|
_this.getChatMessage(entryObject.entryNum, function(err, entry)
|
||||||
{
|
{
|
||||||
entries[entryObject.order] = entry;
|
entries[entryObject.order] = entry;
|
||||||
callback(err);
|
callback(err);
|
||||||
});
|
});
|
||||||
}, function(err)
|
}, function(err)
|
||||||
{
|
{
|
||||||
callback(err, entries);
|
//sort out broken chat entries
|
||||||
|
//it looks like in happend in the past that the chat head was
|
||||||
|
//incremented, but the chat message wasn't added
|
||||||
|
var cleanedEntries = [];
|
||||||
|
for(var i=0;i<entries.length;i++)
|
||||||
|
{
|
||||||
|
if(entries[i]==null)
|
||||||
|
cleanedEntries.push(entries[i]);
|
||||||
|
else
|
||||||
|
console.log("WARNING: Found broken chat entry in pad " + _this.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(err, cleanedEntries);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue