git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 9b3c9dc1b3026aad3249cbeee25be19c38038936

Files: 9b3c9dc1b3026aad3249cbeee25be19c38038936 / feed / pull / channel.js

1085 bytesRaw
1const nest = require('depnest')
2const extend = require('xtend')
3var pull = require('pull-stream')
4
5exports.gives = nest('feed.pull.channel')
6exports.needs = nest({
7 'sbot.pull.backlinks': 'first',
8 'channel.sync.normalize': 'first',
9 'message.sync.isBlocked': 'first',
10 'message.sync.timestamp': 'first'
11})
12
13exports.create = function (api) {
14 return nest('feed.pull.channel', function (channel) {
15 channel = api.channel.sync.normalize(channel)
16 if (typeof channel !== 'string') throw new Error('a channel name be specified')
17
18 return function (opts) {
19 // handle last item passed in as lt
20 var lt = (opts.lt && opts.lt.value)
21 ? api.message.sync.timestamp(opts.lt)
22 : opts.lt
23
24 delete opts.lt
25
26 var filter = {
27 dest: `#${channel}`,
28 rts: typeof lt === 'number' ? {$lt: lt, $gt: 0} : {$gt: 0}
29 }
30
31 return pull(
32 api.sbot.pull.backlinks(extend(opts, {
33 query: [
34 {$filter: filter}
35 ]
36 })),
37 pull.filter(msg => !api.message.sync.isBlocked(msg))
38 )
39 }
40 })
41}
42

Built with git-ssb-web