Files: 53223b8604d4abb25d4300575f28f0076460a02e / feed / pull / mentions.js
964 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 | 'message.sync.isBlocked': 'first' |
9 | }) |
10 | |
11 | exports.gives = nest('feed.pull.mentions') |
12 | |
13 | exports.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