Add debugging tools

This commit is contained in:
yflory
2019-02-25 18:43:32 +01:00
parent 0d996b8ed4
commit ec33084226
9 changed files with 368 additions and 73 deletions

View File

@@ -254,8 +254,8 @@ define([
postMessage("REMOVE_OWNED_CHANNEL", channel, cb);
};
common.getDeletedPads = function (cb) {
postMessage("GET_DELETED_PADS", null, function (obj) {
common.getDeletedPads = function (data, cb) {
postMessage("GET_DELETED_PADS", data, function (obj) {
if (obj && obj.error) { return void cb(obj.error); }
cb(null, obj);
});

View File

@@ -48,14 +48,6 @@ define([
});
};
var loadFullHistory = function (config, common, cb) {
var realtime = createRealtime(config);
common.getFullHistory(realtime, function () {
cb(null, realtime);
});
};
loadFullHistory = loadFullHistory;
var fillChainPad = function (realtime, messages) {
messages.forEach(function (m) {
realtime.message(m);

View File

@@ -514,11 +514,22 @@ define([
channel: secret.channel,
validateKey: secret.keys.validateKey
}, function (encryptedMsgs) {
cb(encryptedMsgs.map(function (msg) {
// 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
return crypto.decrypt(msg, true, true);
}));
var nt = nThen;
var decryptedMsgs = [];
var total = encryptedMsgs.length;
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));
setTimeout(waitFor(function () {
sframeChan.event('EV_FULL_HISTORY_STATUS', (i+1)/total);
}), 5);
}).nThen;
});
nt(function () {
cb(decryptedMsgs);
});
});
});
sframeChan.on('Q_GET_HISTORY_RANGE', function (data, cb) {
@@ -590,6 +601,13 @@ define([
});
});
sframeChan.on('Q_DRIVE_GETDELETED', function (data, cb) {
Cryptpad.getDeletedPads(data, function (err, obj) {
if (err) { return void console.error(err); }
cb(obj);
});
});
sframeChan.on('Q_SESSIONSTORAGE_PUT', function (data, cb) {
sessionStorage[data.key] = data.value;
cb();

View File

@@ -302,17 +302,6 @@ define([
});
};
funcs.getFullHistory = function (realtime, cb) {
ctx.sframeChan.query('Q_GET_FULL_HISTORY', null, function (err, messages) {
if (err) { return void console.error(err); }
if (!Array.isArray(messages)) { return; }
messages.forEach(function (m) {
realtime.message(m);
});
cb();
});
};
// href is optional here: if not provided, we use the href of the current tab
funcs.getPadAttribute = function (key, cb, href) {
ctx.sframeChan.query('Q_GET_PAD_ATTRIBUTE', {