use rpc calls from cryptpad common

pull/1/head
ansuz 8 years ago
parent 7befaccd88
commit 80479fdc90

@ -65,9 +65,8 @@ define([
} }
// if not box then done // if not box then done
Cryptpad.rpc.send('UPLOAD_COMPLETE', '', function (e, res) { Cryptpad.uploadComplete(function (e, id) {
if (e) { return void console.error(e); } if (e) { return void console.error(e); }
var id = res[0];
var uri = ['', 'blob', id.slice(0,2), id].join('/'); var uri = ['', 'blob', id.slice(0,2), id].join('/');
console.log("encrypted blob is now available as %s", uri); console.log("encrypted blob is now available as %s", uri);
@ -78,32 +77,28 @@ define([
APP.toolbar.addElement(['fileshare'], {}); APP.toolbar.addElement(['fileshare'], {});
// check if the uploaded file can be decrypted var title = document.title = metadata.name;
var newU8 = FileCrypto.joinChunks(chunks); myFile = blob;
FileCrypto.decrypt(newU8, key, function (e, res) { myDataType = metadata.type;
if (e) { return console.error(e); } var defaultName = Cryptpad.getDefaultName(Cryptpad.parsePadUrl(window.location.href));
var title = document.title = res.metadata.name; Title.updateTitle(title || defaultName);
myFile = res.content; APP.toolbar.title.show();
myDataType = res.metadata.type; console.log(title);
Cryptpad.alert(Messages._getKey('upload_success', [title]));
var defaultName = Cryptpad.getDefaultName(Cryptpad.parsePadUrl(window.location.href));
Title.updateTitle(title || defaultName);
APP.toolbar.title.show();
Cryptpad.alert(Messages._getKey('upload_success', [title]));
});
}); });
}; };
Cryptpad.rpc.send('UPLOAD_STATUS', estimate, function (e, pending) { Cryptpad.uploadStatus(estimate, function (e, pending) {
if (e) { if (e) {
console.error(e); console.error(e);
return void Cryptpad.alert(Messages.upload_serverError); return void Cryptpad.alert(Messages.upload_serverError);
} }
if (pending[0]) { if (pending) {
// TODO queue uploads... ?
return void Cryptpad.confirm(Messages.upload_uploadPending, function (yes) { return void Cryptpad.confirm(Messages.upload_uploadPending, function (yes) {
if (!yes) { return; } if (!yes) { return; }
Cryptpad.rpc.send('UPLOAD_CANCEL', '', function (e, res) { Cryptpad.uploadCancel(function (e, res) {
if (e) { return void console.error(e); } if (e) { return void console.error(e); }
console.log(res); console.log(res);
next(again); next(again);

Loading…
Cancel
Save