add support for invite hashes

pull/1/head
ansuz 8 years ago
parent e353627204
commit d293ba4d44

@ -54,7 +54,7 @@ Version 1
if (!hash) { return; } if (!hash) { return; }
var parsed = {}; var parsed = {};
var hashArr = fixDuplicateSlashes(hash).split('/'); var hashArr = fixDuplicateSlashes(hash).split('/');
if (['media', 'file', 'user'].indexOf(type) === -1) { if (['media', 'file', 'user', 'invite'].indexOf(type) === -1) {
parsed.type = 'pad'; parsed.type = 'pad';
if (hash.slice(0,1) !== '/' && hash.length >= 56) { if (hash.slice(0,1) !== '/' && hash.length >= 56) {
// Old hash // Old hash
@ -93,6 +93,16 @@ Version 1
} }
return parsed; return parsed;
} }
if (['invite'].indexOf(type) !== -1) {
parsed.type = 'invite';
if (hashArr[1] && hashArr[1] === '1') {
parsed.version = 1;
parsed.channel = hashArr[2];
parsed.pubkey = hashArr[3].replace(/-/g, '/');
return parsed;
}
return parsed;
}
return; return;
}; };
var parsePadUrl = Hash.parsePadUrl = function (href) { var parsePadUrl = Hash.parsePadUrl = function (href) {
@ -320,5 +330,11 @@ Version 1
return hash; return hash;
}; };
Hash.createInviteUrl = function (curvePublic, channel) {
channel = channel || Hash.createChannelId();
return window.location.origin + '/invite/#/1/' + channel +
'/' + curvePublic.replace(/\//g, '-') + '/';
};
return Hash; return Hash;
}); });

@ -107,6 +107,7 @@ define([
common.findWeaker = Hash.findWeaker; common.findWeaker = Hash.findWeaker;
common.findStronger = Hash.findStronger; common.findStronger = Hash.findStronger;
common.serializeHash = Hash.serializeHash; common.serializeHash = Hash.serializeHash;
common.createInviteUrl = Hash.createInviteUrl;
// Userlist // Userlist
common.createUserList = UserList.create; common.createUserList = UserList.create;

Loading…
Cancel
Save