git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 4ff3dd24fadc8bffcd79936dec7a644eb40ef22d

Files: 4ff3dd24fadc8bffcd79936dec7a644eb40ef22d / feed / pull / mentions.js

843 bytesRaw
1const nest = require('depnest')
2const extend = require('xtend')
3const pull = require('pull-stream')
4const ref = require('ssb-ref')
5
6exports.needs = nest({
7 'sbot.pull.backlinks': 'first'
8})
9
10exports.gives = nest('feed.pull.mentions')
11
12exports.create = function (api) {
13 return nest('feed.pull.mentions', function (id) {
14 if (!ref.isFeed(id)) throw new Error('a feed id must be specified')
15
16 return function getStream (opts) {
17 // handle last item passed in as lt
18 var lt = (opts.lt && opts.lt.value)
19 ? opts.lt.timestamp
20 : opts.lt
21
22 opts = extend(opts, {
23 lt: undefined,
24 query: [
25 {$filter: {
26 dest: id,
27 timestamp: typeof lt === 'number' ? {$lt: lt, $gt: 0} : {$gt: 0}
28 }}
29 ]
30 })
31
32 return api.sbot.pull.backlinks(opts)
33 }
34 })
35}
36

Built with git-ssb-web