Files: 53223b8604d4abb25d4300575f28f0076460a02e / feed / pull / type.js
750 bytesRaw
1 | const nest = require('depnest') |
2 | const extend = require('xtend') |
3 | const pull = require('pull-stream') |
4 | |
5 | exports.gives = nest('feed.pull.type') |
6 | exports.needs = nest({ |
7 | 'sbot.pull.messagesByType': 'first', |
8 | 'message.sync.isBlocked': 'first' |
9 | }) |
10 | |
11 | exports.create = function (api) { |
12 | return nest('feed.pull.type', (type) => { |
13 | if (typeof type !== 'string') throw new Error('a type must be specified') |
14 | |
15 | return function (opts) { |
16 | opts = extend(opts, { |
17 | type, |
18 | // handle last item passed in as lt |
19 | lt: opts.lt && typeof opts.lt === 'object' ? opts.lt.timestamp : opts.lt |
20 | }) |
21 | |
22 | return pull( |
23 | api.sbot.pull.messagesByType(opts), |
24 | pull.filter(msg => !api.message.sync.isBlocked(msg)) |
25 | ) |
26 | } |
27 | }) |
28 | } |
29 |
Built with git-ssb-web