Commit b0afea5e68a6a31afda1eeb38830433a9beedd2b
use ssb-contacts for contact.async, now removed all uses of sbot.pull.query
Matt McKegg committed on 6/12/2017, 1:27:59 PMParent: a35242aa5cf18d28921e8c879cab704c7680f8d0
Files changed
contact/async.js | changed |
contact/async.js | ||
---|---|---|
@@ -1,10 +1,11 @@ | ||
1 | 1 … | var nest = require('depnest') |
2 | -var pull = require('pull-stream') | |
2 … | +var onceTrue = require('mutant/once-true') | |
3 … | +var resolve = require('mutant/resolve') | |
3 | 4 … | var ref = require('ssb-ref') |
4 | 5 … | |
5 | 6 … | exports.needs = nest({ |
6 | - 'sbot.pull.query': 'first', | |
7 … | + 'contact.obs.following': 'first', | |
7 | 8 … | 'sbot.async.publish': 'first' |
8 | 9 … | }) |
9 | 10 … | |
10 | 11 … | exports.gives = nest({ |
@@ -16,18 +17,13 @@ | ||
16 | 17 … | 'contact.async': {follow, unfollow, followerOf} |
17 | 18 … | }) |
18 | 19 … | |
19 | 20 … | function followerOf (source, dest, cb) { |
20 | - pull( | |
21 | - api.sbot.pull.query({query: [ | |
22 | - makeQuery(source, dest), | |
23 | - {$map: ['value', 'content', 'following']} | |
24 | - ]}), | |
25 | - pull.collect(function (err, ary) { | |
26 | - if (err) return cb(err) | |
27 | - else cb(null, ary.pop()) // will be true, or undefined/false | |
28 | - }) | |
29 | - ) | |
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 … | + }) | |
30 | 26 … | } |
31 | 27 … | |
32 | 28 … | function follow (id, cb) { |
33 | 29 … | if (!ref.isFeed(id)) throw new Error('a feed id must be specified') |
@@ -46,17 +42,4 @@ | ||
46 | 42 … | following: false |
47 | 43 … | }, cb) |
48 | 44 … | } |
49 | 45 … | } |
50 | - | |
51 | -function makeQuery (a, b) { | |
52 | - return {'$filter': { | |
53 | - value: { | |
54 | - author: a, | |
55 | - content: { | |
56 | - type: 'contact', | |
57 | - contact: b, | |
58 | - following: true | |
59 | - } | |
60 | - } | |
61 | - }} | |
62 | -} |
Built with git-ssb-web