git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 9e85f1068f54ff3bc4458e10ee35cd4f89c31434

Files: 9e85f1068f54ff3bc4458e10ee35cd4f89c31434 / feed / pull / mentions.js

964 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 'message.sync.isBlocked': 'first'
9})
10
11exports.gives = nest('feed.pull.mentions')
12
13exports.create = function (api) {
14 return nest('feed.pull.mentions', function (id) {
15 if (!ref.isFeed(id)) throw new Error('a feed id must be specified')
16
17 return function getStream (opts) {
18 // handle last item passed in as lt
19 var lt = (opts.lt && opts.lt.value)
20 ? opts.lt.timestamp
21 : opts.lt
22
23 opts = extend(opts, {
24 lt: undefined,
25 query: [
26 {$filter: {
27 dest: id,
28 timestamp: typeof lt === 'number' ? {$lt: lt, $gt: 0} : {$gt: 0}
29 }}
30 ]
31 })
32
33 return pull(
34 api.sbot.pull.backlinks(opts),
35 pull.filter(msg => !api.message.sync.isBlocked(msg))
36 )
37 }
38 })
39}
40

Built with git-ssb-web