Files: b9299acd52bd20bcb8bccd4967b2340534b6f1e7 / message / obs / backlinks.js
927 bytesRaw
1 | var nest = require('depnest') |
2 | var MutantPullReduce = require('mutant-pull-reduce') |
3 | |
4 | exports.needs = nest({ |
5 | 'sbot.pull.backlinks': 'first' |
6 | }) |
7 | |
8 | exports.gives = nest('message.obs.backlinks', true) |
9 | |
10 | exports.create = function (api) { |
11 | return nest({ |
12 | 'message.obs.backlinks': (id) => backlinks(id) |
13 | }) |
14 | |
15 | function backlinks (id) { |
16 | return MutantPullReduce(api.sbot.pull.backlinks({ |
17 | query: [ |
18 | {$filter: { |
19 | dest: id |
20 | }}, |
21 | {$map: { |
22 | dest: 'dest', |
23 | id: 'key', |
24 | timestamp: 'timestamp', |
25 | type: ['value', 'content', 'type'], |
26 | root: ['value', 'content', 'root'], |
27 | branch: ['value', 'content', 'branch'], |
28 | author: ['value', 'author'] |
29 | }} |
30 | ] |
31 | }), (result, msg) => { |
32 | if (msg.type !== 'vote' && msg.type !== 'about') { |
33 | result.push(msg) |
34 | } |
35 | return result |
36 | }, { |
37 | startValue: [] |
38 | }) |
39 | } |
40 | } |
41 |
Built with git-ssb-web