git ssb

7+

dinoworm 🐛 / patchcore



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 PM
Parent: a35242aa5cf18d28921e8c879cab704c7680f8d0

Files changed

contact/async.jschanged
contact/async.jsView
@@ -1,10 +1,11 @@
11 var nest = require('depnest')
2-var pull = require('pull-stream')
2 +var onceTrue = require('mutant/once-true')
3 +var resolve = require('mutant/resolve')
34 var ref = require('ssb-ref')
45
56 exports.needs = nest({
6- 'sbot.pull.query': 'first',
7 + 'contact.obs.following': 'first',
78 'sbot.async.publish': 'first'
89 })
910
1011 exports.gives = nest({
@@ -16,18 +17,13 @@
1617 'contact.async': {follow, unfollow, followerOf}
1718 })
1819
1920 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 + })
3026 }
3127
3228 function follow (id, cb) {
3329 if (!ref.isFeed(id)) throw new Error('a feed id must be specified')
@@ -46,17 +42,4 @@
4642 following: false
4743 }, cb)
4844 }
4945 }
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