git ssb

7+

dinoworm 🐛 / patchcore



Commit 3a6b42e980da99c6778fd2db5f693fa7d89d7207

Merge pull request #30 from ssbc/caps

use caps
mix irving authored on 8/21/2017, 4:28:57 AM
GitHub committed on 8/21/2017, 4:28:57 AM
Parent: dd429902f3108d6b49d95c16ad3d853cfc7dc12a
Parent: 4c04e7c94d477b89e0a5fca62c30370df719af11

Files changed

contact/async.jschanged
invite.jschanged
sbot.jschanged
contact/async.jsView
@@ -4,9 +4,10 @@
44 var ref = require('ssb-ref')
55
66 exports.needs = nest({
77 'contact.obs.following': 'first',
8- 'sbot.async.publish': 'first'
8 + 'sbot.async.publish': 'first',
9 + 'sbot.async.friendsGet': 'first'
910 })
1011
1112 exports.gives = nest({
1213 'contact.async': ['follow', 'unfollow', 'followerOf']
@@ -17,13 +18,9 @@
1718 'contact.async': {follow, unfollow, followerOf}
1819 })
1920
2021 function followerOf (source, dest, cb) {
21- var following = api.contact.obs.following(source)
22- onceTrue(following.sync, () => {
23- var value = resolve(following)
24- cb(null, value && value.has(dest))
25- })
22 + api.sbot.async.friendsGet({source: source, dest: dest}, cb)
2623 }
2724
2825 function follow (id, cb) {
2926 if (!ref.isFeed(id)) throw new Error('a feed id must be specified')
@@ -42,4 +39,8 @@
4239 following: false
4340 }, cb)
4441 }
4542 }
43 +
44 +
45 +
46 +
invite.jsView
@@ -7,9 +7,10 @@
77 exports.needs = nest({
88 'sbot.async.publish': 'first',
99 'sbot.async.gossipConnect': 'first',
1010 'contact.async.followerOf': 'first',
11- 'keys.sync.id': 'first'
11 + 'keys.sync.id': 'first',
12 + 'config.sync.load': 'first'
1213 })
1314
1415 exports.gives = nest({
1516 'invite.async.accept': true,
@@ -20,8 +21,11 @@
2021 function accept (invite, cb) {
2122 var progress = Value('Connecting...')
2223 var data = ref.parseInvite(invite)
2324 var id = api.keys.sync.id()
25 +
26 + var config = api.config.sync.load()
27 +
2428 if (!data) return cb(new Error('Not a valid invite code. Please make sure you copied the entire code and try again.'))
2529
2630 api.sbot.async.gossipConnect(data.remote, function (err) {
2731 if (err) console.log(err)
@@ -29,9 +33,10 @@
2933
3034 // connect to the remote pub using the invite code
3135 ssbClient(null, {
3236 remote: data.invite,
33- manifest: { invite: {use: 'async'}, getAddress: 'async' }
37 + manifest: { invite: {use: 'async'}, getAddress: 'async' },
38 + appKey: config.caps.shs
3439 }, function (err, sbot) {
3540 if (err) return cb(err)
3641 progress.set('Requesting follow...')
3742
@@ -81,9 +86,9 @@
8186 var id = api.keys.sync.id()
8287 var data = ref.parseInvite(invite)
8388 api.contact.async.followerOf(id, data.key, function (_, follows) {
8489 if (follows) console.log('already following', cb())
85- else accept(invite, cb)
90 + else console.log('accept invite:'+invite, accept(invite, cb))
8691 })
8792 }
8893 })
8994 }
sbot.jsView
@@ -23,9 +23,10 @@
2323 async: {
2424 get: true,
2525 publish: true,
2626 addBlob: true,
27- gossipConnect: true
27 + gossipConnect: true,
28 + friendsGet: true
2829 },
2930 pull: {
3031 log: true,
3132 userFeed: true,
@@ -59,9 +60,19 @@
5960 function notify (value) {
6061 isConn(value); connectionStatus.set(value)
6162 }
6263
63- createClient(keys, config, function (err, _sbot) {
64 + var opts = {
65 + path: config.path,
66 + remote: config.remote,
67 + host: config.host,
68 + port: config.port,
69 + key: config.key,
70 + appKey: config.caps.shs,
71 + timers: config.timers
72 + }
73 +
74 + createClient(keys, opts, function (err, _sbot) {
6475 if (err) {
6576 return notify(err)
6677 }
6778
@@ -178,8 +189,11 @@
178189 )
179190 }),
180191 gossipConnect: rec.async(function (opts, cb) {
181192 sbot.gossip.connect(opts, cb)
193 + }),
194 + friendsGet: rec.async(function (opts, cb) {
195 + sbot.friends.get(opts, cb)
182196 })
183197 },
184198 pull: {
185199 backlinks: rec.source(query => {

Built with git-ssb-web