Provide the secondaryKey to userObject

This commit is contained in:
yflory
2019-10-07 14:35:11 +02:00
parent dd2f0bd417
commit cf0d0e8e4b
11 changed files with 62 additions and 46 deletions

View File

@@ -420,39 +420,6 @@ Version 1
};
// STORAGE
Hash.findWeaker = function (href, channel, recents) {
var parsed = parsePadUrl(href);
if (!parsed.hash) { return false; }
// We can't have a weaker hash if we're already in view mode
if (parsed.hashData && parsed.hashData.mode === 'view') { return; }
var weaker;
Object.keys(recents).some(function (id) {
var pad = recents[id];
if (pad.href || !pad.roHref) {
// This pad has an edit link, so it can't be weaker
return;
}
var p = parsePadUrl(pad.roHref);
if (p.type !== parsed.type) { return; } // Not the same type
if (p.hash === parsed.hash) { return; } // Same hash, not stronger
if (channel !== pad.channel) { return; } // Not the same channel
var pHash = p.hashData;
var parsedHash = parsed.hashData;
if (!parsedHash || !pHash) { return; }
// We don't have stronger/weaker versions of files or users
if (pHash.type !== 'pad' && parsedHash.type !== 'pad') { return; }
if (pHash.version !== parsedHash.version) { return; }
if (pHash.mode === 'view' && parsedHash.mode === 'edit') {
weaker = pad;
return true;
}
return;
});
return weaker;
};
Hash.findStronger = function (href, channel, recents) {
var parsed = parsePadUrl(href);
if (!parsed.hash) { return false; }
@@ -472,6 +439,7 @@ Version 1
if (channel !== pad.channel) { return; }
// If this pad doesn't have an edit link, it can't be stronger
// XXX encrypted href
if (!pad.href || !pad.roHref) { return; }
// This is a pad with an EDIT href and using the same channel as our target