Remove the second network created for the drive

This commit is contained in:
yflory
2017-12-05 16:40:04 +01:00
parent 52712c4bb9
commit 17636769e4
11 changed files with 1137 additions and 683 deletions

View File

@@ -298,36 +298,15 @@ define([
};
sframeChan.on('Q_GET_FULL_HISTORY', function (data, cb) {
var hkn = network.historyKeeper;
var crypto = Crypto.createEncryptor(secret.keys);
// Get the history messages and send them to the iframe
var parse = function (msg) {
try {
return JSON.parse(msg);
} catch (e) {
return null;
}
};
var msgs = [];
var onMsg = function (msg) {
var parsed = parse(msg);
if (parsed[0] === 'FULL_HISTORY_END') {
cb(msgs);
return;
}
if (parsed[0] !== 'FULL_HISTORY') { return; }
if (parsed[1] && parsed[1].validateKey) { // First message
return;
}
msg = parsed[1][4];
if (msg) {
msg = msg.replace(/^cp\|/, '');
var decryptedMsg = crypto.decrypt(msg, true);
msgs.push(decryptedMsg);
}
};
network.on('message', onMsg);
network.sendto(hkn, JSON.stringify(['GET_FULL_HISTORY', secret.channel, secret.keys.validateKey]));
Cryptpad.getFullHistory({
channel: secret.channel,
validateKey: secret.keys.validateKey
}, function (encryptedMsgs) {
cb(encryptedMsgs.map(function (msg) {
return crypto.decrypt(msg, true);
}));
});
});
sframeChan.on('Q_GET_PAD_ATTRIBUTE', function (data, cb) {
@@ -594,7 +573,7 @@ define([
return;
}
if (readOnly || cfg.noHash) { return; }
replaceHash(Utils.Hash.getEditHashFromKeys(wc.id, secret.keys));
replaceHash(Utils.Hash.getEditHashFromKeys(wc, secret.keys));
}
});
});