Commit b67ed19d6fbf76c870c96c70cb920c9eda385257
add relationships module
Dominic Tarr committed on 7/25/2016, 12:34:44 AMParent: f32aaca1352e9cd82c3584608228beda59e2a946
Files changed
modules/index.js | changed |
modules/relationships.js | added |
modules/index.js | ||
---|---|---|
@@ -11,8 +11,9 @@ | ||
11 | 11 | "crypto.js": require('./crypto.js'), |
12 | 12 | "feed.js": require('./feed.js'), |
13 | 13 | "file-input.js": require('./file-input.js'), |
14 | 14 | "follow.js": require('./follow.js'), |
15 | + "relationships.js": require('./relationships.js'), | |
15 | 16 | "invite.js": require('./invite.js'), |
16 | 17 | "like.js": require('./like.js'), |
17 | 18 | "markdown.js": require('./markdown.js'), |
18 | 19 | "message-confirm.js": require('./message-confirm.js'), |
modules/relationships.js | ||
---|---|---|
@@ -1,0 +1,23 @@ | ||
1 | + | |
2 | +var plugs = require('../plugs') | |
3 | + | |
4 | +var sbot_links2 = plugs.first(exports.sbot_links2 = []) | |
5 | + | |
6 | +//this is a bit crude, and doesn't actually show unfollows yet. | |
7 | + | |
8 | +exports.follows = function (id, cb) { | |
9 | + return sbot_links2({query: [ | |
10 | + {"$filter": {"source": id, "rel": ["contact", true, false] }}, | |
11 | + {"$map": "dest"} | |
12 | + ]}) | |
13 | +} | |
14 | + | |
15 | +exports.followers = function (id) { | |
16 | + return sbot_links2({query: [ | |
17 | + {"$filter": {"dest": id, "rel": ["contact", true, false] }}, | |
18 | + {"$map": "source"} | |
19 | + ]}) | |
20 | +} | |
21 | + | |
22 | + | |
23 | + |
Built with git-ssb-web