Replay history in order
This commit is contained in:
@@ -1880,7 +1880,15 @@ define([
|
||||
if (msg) {
|
||||
msg = msg.replace(/cp\|(([A-Za-z0-9+\/=]+)\|)?/, '');
|
||||
//var decryptedMsg = crypto.decrypt(msg, true);
|
||||
msgs.push(msg);
|
||||
if (data.debug) {
|
||||
msgs.push({
|
||||
msg: msg,
|
||||
author: parsed[1][1],
|
||||
time: parsed[1][5]
|
||||
});
|
||||
} else {
|
||||
msgs.push(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
network.on('message', onMsg);
|
||||
|
||||
@@ -71,7 +71,10 @@ define([
|
||||
lastKnownHash = data.lastKnownHash;
|
||||
isComplete = data.isFull;
|
||||
var messages = (data.messages || []).map(function (obj) {
|
||||
return obj.msg;
|
||||
if (!config.debug) {
|
||||
return obj.msg;
|
||||
}
|
||||
return obj;
|
||||
});
|
||||
if (config.debug) { console.log(data.messages); }
|
||||
Array.prototype.unshift.apply(allMessages, messages); // Destructive concat
|
||||
|
||||
@@ -835,17 +835,26 @@ define([
|
||||
sframeChan.on('Q_GET_FULL_HISTORY', function (data, cb) {
|
||||
var crypto = Crypto.createEncryptor(secret.keys);
|
||||
Cryptpad.getFullHistory({
|
||||
debug: data && data.debug,
|
||||
channel: secret.channel,
|
||||
validateKey: secret.keys.validateKey
|
||||
}, function (encryptedMsgs) {
|
||||
var nt = nThen;
|
||||
var decryptedMsgs = [];
|
||||
var total = encryptedMsgs.length;
|
||||
encryptedMsgs.forEach(function (msg, i) {
|
||||
encryptedMsgs.forEach(function (_msg, i) {
|
||||
nt = nt(function (waitFor) {
|
||||
// The 3rd parameter "true" means we're going to skip signature validation.
|
||||
// We don't need it since the message is already validated serverside by hk
|
||||
decryptedMsgs.push(crypto.decrypt(msg, true, true));
|
||||
if (typeof(_msg) === "object") {
|
||||
decryptedMsgs.push({
|
||||
author: _msg.author,
|
||||
time: _msg.time,
|
||||
msg: crypto.decrypt(_msg.msg, true, true)
|
||||
});
|
||||
} else {
|
||||
decryptedMsgs.push(crypto.decrypt(_msg.msg, true, true));
|
||||
}
|
||||
setTimeout(waitFor(function () {
|
||||
sframeChan.event('EV_FULL_HISTORY_STATUS', (i+1)/total);
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user