git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: d06c60e3b13b5795e7acad4aff8901f5039efb83

Files: d06c60e3b13b5795e7acad4aff8901f5039efb83 / message / obs / backlinks.js

927 bytesRaw
1var nest = require('depnest')
2var MutantPullReduce = require('mutant-pull-reduce')
3
4exports.needs = nest({
5 'sbot.pull.backlinks': 'first'
6})
7
8exports.gives = nest('message.obs.backlinks', true)
9
10exports.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