git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 7c4d6df66f14e6f9d83ca2763a2fcd102369592e

Files: 7c4d6df66f14e6f9d83ca2763a2fcd102369592e / feed / pull / channel.js

1120 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 value: {
29 timestamp: typeof lt === 'number' ? {$lt: lt, $gt: 0} : {$gt: 0}
30 }
31 }
32
33 return pull(
34 api.sbot.pull.backlinks(extend(opts, {
35 query: [
36 {$filter: filter}
37 ]
38 })),
39 pull.filter(msg => !api.message.sync.isBlocked(msg))
40 )
41 }
42 })
43}
44

Built with git-ssb-web