optimize file upload

This commit is contained in:
ansuz
2017-06-01 18:16:02 +02:00
parent eb78ed072a
commit f631973f1f
3 changed files with 33 additions and 4 deletions

View File

@@ -129,6 +129,24 @@ types of messages:
return sendMsg(ctx, data, cb);
};
send.unauthenticated = function (type, msg, cb) {
if (!ctx.connected) {
return void window.setTimeout(function () {
cb('DISCONNECTED');
});
}
// construct an unsigned message
var data = [null, edPublicKey, null, type, msg];
if (ctx.cookie && ctx.cookie.join) {
data[2] = ctx.cookie.join('|');
} else {
data[2] = ctx.cookie;
}
return sendMsg(ctx, data, cb);
};
network.on('message', function (msg) {
onMsg(ctx, msg);
});

View File

@@ -65,7 +65,7 @@ define([
var enc = Nacl.util.encodeBase64(box);
chunks.push(box);
Cryptpad.rpc.send('UPLOAD', enc, function (e, msg) {
Cryptpad.rpc.send.unauthenticated('UPLOAD', enc, function (e, msg) {
console.log(box);
cb(e, msg);
});