Use the hidden hash when opening a pad from the drive
parent
83c35543b9
commit
718610b6db
|
@ -68,10 +68,9 @@ var factory = function (Util, Crypto, Nacl) {
|
|||
if (secret.keys && secret.keys.fileKeyStr) { mode = ''; }
|
||||
|
||||
var hash = '/3/' + type + '/' + mode + secret.channel + '/' + pass;
|
||||
var href = '/' + type + '/#' + hash;
|
||||
var parsed = Hash.parsePadUrl(href);
|
||||
if (parsed.hashData && parsed.hashData.getHash) {
|
||||
return parsed.hashData.getHash(opts || {});
|
||||
var hashData = Hash.parseTypeHash(type, hash);
|
||||
if (hashData && hashData.getHash) {
|
||||
return hashData.getHash(opts || {});
|
||||
}
|
||||
return hash;
|
||||
};
|
||||
|
@ -380,6 +379,14 @@ Version 1
|
|||
return ret;
|
||||
};
|
||||
|
||||
Hash.hashToHref = function (hash, type) {
|
||||
return '/' + type + '/#' + hash;
|
||||
};
|
||||
Hash.hrefToHref = function (href) {
|
||||
var parsed = parsedPadUrl(href);
|
||||
return parsed.hash;
|
||||
};
|
||||
|
||||
Hash.getRelativeHref = function (href) {
|
||||
if (!href) { return; }
|
||||
if (href.indexOf('#') === -1) { return; }
|
||||
|
|
|
@ -1029,15 +1029,18 @@ define([
|
|||
return ret;
|
||||
};
|
||||
|
||||
var openFile = function (el, href) {
|
||||
if (!href) {
|
||||
var data = manager.getFileData(el);
|
||||
if (!data || (!data.href && !data.roHref)) {
|
||||
return void logError("Missing data for the file", el, data);
|
||||
}
|
||||
href = data.href || data.roHref;
|
||||
var openFile = function (el, isRo) {
|
||||
var data = manager.getFileData(el);
|
||||
if (!data || (!data.href && !data.roHref)) {
|
||||
return void logError("Missing data for the file", el, data);
|
||||
}
|
||||
window.open(APP.origin + href);
|
||||
var href = data.href || data.roHref;
|
||||
var parsed = Hash.parsePadUrl(href);
|
||||
var secret = Hash.getSecrets(parsed.type, parsed.hash, data.password);
|
||||
var hash = Hash.getHiddenHashFromKeys(parsed.type, secret);
|
||||
var hiddenHref = Hash.hashToHref(hash, parsed.type);
|
||||
// XXX hidden hash: use settings
|
||||
window.open(APP.origin + hiddenHref);
|
||||
};
|
||||
|
||||
var refresh = APP.refresh = function () {
|
||||
|
@ -3034,7 +3037,7 @@ define([
|
|||
$icon.append(getFileIcon(r.id));
|
||||
$type.text(Messages.type[parsed.type] || parsed.type);
|
||||
$title.click(function () {
|
||||
openFile(null, r.data.href);
|
||||
openFile(r.id);
|
||||
});
|
||||
$atimeName.text(Messages.fm_lastAccess);
|
||||
$atime.text(new Date(r.data.atime).toLocaleString());
|
||||
|
@ -3944,15 +3947,12 @@ define([
|
|||
// ANON_SHARED_FOLDER
|
||||
el = manager.find(paths[0].path.slice(1), APP.newSharedFolder);
|
||||
}
|
||||
var href;
|
||||
if (manager.isPathIn(p.path, [FILES_DATA])) {
|
||||
href = el.roHref;
|
||||
el = p.path[1];
|
||||
} else {
|
||||
if (!el || manager.isFolder(el)) { return; }
|
||||
var data = manager.getFileData(el);
|
||||
href = data.roHref;
|
||||
}
|
||||
openFile(null, href);
|
||||
openFile(el, true);
|
||||
});
|
||||
}
|
||||
else if ($this.hasClass('cp-app-drive-context-openincode')) {
|
||||
|
|
Loading…
Reference in New Issue