git ssb

0+

Dominic / ssb-peer-invites



Commit 4b1b1ba0345c0011c30ae657833f8b4b0b375204

accept a cap passed in on the invite, to support #blockparty @jfr @regular

Dominic Tarr committed on 12/20/2018, 9:53:30 PM
Parent: a41f157208371363a64d45872e71c9ee8a1812de

Files changed

index.jschanged
index.jsView
@@ -326,17 +326,18 @@
326326 })
327327 }
328328
329329 //try each of an array of addresses, and cb the first one that works.
330- function connectFirst (keys, pubs, cb) {
330 + function connectFirst (invite, cb) {
331331 var n = 0, err
332- pubs.forEach(function (addr) {
332 + var keys = ssbKeys.generate(null, invite.seed)
333 + invite.pubs.forEach(function (addr) {
333334 n++
334335 //don't use sbot.connect here, because we are connecting
335336 //with a different cap.
336337 ssbClient(keys, {
337338 remote: addr,
338- caps: caps,
339 + caps: {shs: invite.cap || caps.shs},
339340 manifest: {
340341 userInvites: {
341342 getInvite: 'async',
342343 confirm: 'async'
@@ -359,19 +360,16 @@
359360 invites.openInvite = function (invite, cb) {
360361 invites.getInvite(invite.invite, function (err, msg) {
361362 if(msg)
362363 next(msg)
363- else {
364- var pubs = invite.pubs
365- var keys = ssbKeys.generate(null, invite.seed)
366- connectFirst(keys, pubs, function (err, rpc) {
364 + else
365 + connectFirst(invite, function (err, rpc) {
367366 if(err) return cb(err)
368367 rpc.userInvites.getInvite(invite.invite, function (err, msg) {
369368 if(err) return cb(err)
370369 next(msg)
371370 })
372371 })
373- }
374372
375373 function next (msg) {
376374 var invite_id = '%'+ssbKeys.hash(JSON.stringify(msg, null, 2))
377375 if(invite.invite !== invite_id)
@@ -419,11 +417,9 @@
419417
420418 function next(accept) {
421419 getConfirm(invite_id, accept, function (err, confirm) {
422420 if(!confirm)
423- var pubs = invite.pubs
424- var keys = ssbKeys.generate(null, invite.seed)
425- connectFirst(keys, pubs, function (err, rpc) {
421 + connectFirst(invite, function (err, rpc) {
426422 if(err) return cb(err)
427423 rpc.userInvites.confirm(accept, function (err, confirm) {
428424 //TODO: store confirms for us in the state.
429425 cb(err, confirm)
@@ -436,6 +432,4 @@
436432 return invites
437433 }
438434
439435
440-
441-

Built with git-ssb-web