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 PMParent: a41f157208371363a64d45872e71c9ee8a1812de
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -326,17 +326,18 @@ | ||
326 | 326 … | }) |
327 | 327 … | } |
328 | 328 … | |
329 | 329 … | //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) { | |
331 | 331 … | var n = 0, err |
332 | - pubs.forEach(function (addr) { | |
332 … | + var keys = ssbKeys.generate(null, invite.seed) | |
333 … | + invite.pubs.forEach(function (addr) { | |
333 | 334 … | n++ |
334 | 335 … | //don't use sbot.connect here, because we are connecting |
335 | 336 … | //with a different cap. |
336 | 337 … | ssbClient(keys, { |
337 | 338 … | remote: addr, |
338 | - caps: caps, | |
339 … | + caps: {shs: invite.cap || caps.shs}, | |
339 | 340 … | manifest: { |
340 | 341 … | userInvites: { |
341 | 342 … | getInvite: 'async', |
342 | 343 … | confirm: 'async' |
@@ -359,19 +360,16 @@ | ||
359 | 360 … | invites.openInvite = function (invite, cb) { |
360 | 361 … | invites.getInvite(invite.invite, function (err, msg) { |
361 | 362 … | if(msg) |
362 | 363 … | 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) { | |
367 | 366 … | if(err) return cb(err) |
368 | 367 … | rpc.userInvites.getInvite(invite.invite, function (err, msg) { |
369 | 368 … | if(err) return cb(err) |
370 | 369 … | next(msg) |
371 | 370 … | }) |
372 | 371 … | }) |
373 | - } | |
374 | 372 … | |
375 | 373 … | function next (msg) { |
376 | 374 … | var invite_id = '%'+ssbKeys.hash(JSON.stringify(msg, null, 2)) |
377 | 375 … | if(invite.invite !== invite_id) |
@@ -419,11 +417,9 @@ | ||
419 | 417 … | |
420 | 418 … | function next(accept) { |
421 | 419 … | getConfirm(invite_id, accept, function (err, confirm) { |
422 | 420 … | 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) { | |
426 | 422 … | if(err) return cb(err) |
427 | 423 … | rpc.userInvites.confirm(accept, function (err, confirm) { |
428 | 424 … | //TODO: store confirms for us in the state. |
429 | 425 … | cb(err, confirm) |
@@ -436,6 +432,4 @@ | ||
436 | 432 … | return invites |
437 | 433 … | } |
438 | 434 … | |
439 | 435 … | |
440 | - | |
441 | - |
Built with git-ssb-web