Files: a732bc2a78bd9ce1b2bff429591d2b85f9a86306 / feed / pull / mentions.js
843 bytesRaw
1 | const nest = require('depnest') |
2 | const extend = require('xtend') |
3 | const pull = require('pull-stream') |
4 | const ref = require('ssb-ref') |
5 | |
6 | exports.needs = nest({ |
7 | 'sbot.pull.backlinks': 'first' |
8 | }) |
9 | |
10 | exports.gives = nest('feed.pull.mentions') |
11 | |
12 | exports.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