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