git ssb

0+

ev / microbay



forked from Dominic / patchbay

Commit 1a4ccb4dc20d081f7f29e659e14b850e48e14a96

fix bugs in invite codes, redirect properly

Dominic Tarr committed on 7/30/2016, 4:08:02 AM
Parent: e257f2546f229a035921db80e8d18ba65b25c615

Files changed

modules/invite.jschanged
modules/invite.jsView
@@ -12,9 +12,12 @@
1212
1313 //check that invite is
1414 // ws:...~shs:key:seed
1515 function parseMultiServerInvite (invite) {
16- var parts = invite.split('~')
16+ var redirect = invite.split('#')
17+ if(!redirect.length) return null
18+
19+ var parts = redirect[0].split('~')
1720 .map(function (e) { return e.split(':') })
1821
1922 if(parts.length !== 2) return null
2023 if(!/^(net|wss?)$/.test(parts[0][0])) return null
@@ -23,10 +26,11 @@
2326 var p2 = invite.split(':')
2427 p2.pop()
2528
2629 return {
27- invite: invite,
30+ invite: redirect[0],
2831 remote: p2.join(':'),
32+ redirect: '#' + redirect.slice(1).join('#')
2933 }
3034 }
3135
3236 exports.screen_view = function (invite) {
@@ -42,9 +46,9 @@
4246 //post follow pub
4347 var div = h('div.column',
4448 h('div',
4549 "you have been invited to join:", h('br'),
46- h('code', invite)
50+ h('code', data.invite)
4751 ),
4852 h('button', 'accept', {onclick: attempt}),
4953 progress
5054 )
@@ -52,9 +56,9 @@
5256 function attempt () {
5357 progress.reset().next('connecting...')
5458
5559 ssbClient(null, {
56- remote: invite,
60+ remote: data.invite,
5761 manifest: { invite: {use: 'async'}, getAddress: 'async' }
5862 }, function (err, sbot) {
5963 if(err) return progress.fail(err)
6064 progress.next('requesting follow...')
@@ -78,24 +82,24 @@
7882 if(err) return progress.fail(err)
7983 progress.complete()
8084 //check for redirect
8185 var parts = location.hash.substring(1).split('#')
86+
8287 //TODO: handle in a consistent way with either hashrouting
8388 //or with tabs...
84- if(parts[0] === invite) location.hash = '#'
89+ if(parts[0] === data.invite)
90+ location.hash = data.redirect
91+ else
92+ console.log("NO REDIRECT")
8593 })
8694 })
8795 })
8896 }
8997
9098 // If we are in the browser,
9199 // and do not already have a remote set, automatically trigger the invite.
92-
93100 if(process.title == 'browser' && !localStorage.remote) attempt()
94101
95102 return div
96103 }
97104
98105
99-
100-
101-

Built with git-ssb-web