Files: f6a49ebd9fb233e15e04deecd49ddcbc3f6a4857 / feed / pull / type.js
850 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 | 'contact.obs.blocking': 'first', |
9 | 'keys.sync.id': 'first' |
10 | }) |
11 | |
12 | exports.create = function (api) { |
13 | return nest('feed.pull.type', (type) => { |
14 | if (typeof type !== 'string') throw new Error('a type must be specified') |
15 | |
16 | return function (opts) { |
17 | opts = extend(opts, { |
18 | type, |
19 | // handle last item passed in as lt |
20 | lt: opts.lt && typeof opts.lt === 'object' ? opts.lt.timestamp : opts.lt |
21 | }) |
22 | |
23 | const blocking = api.contact.obs.blocking(api.keys.sync.id()) |
24 | |
25 | return pull( |
26 | api.sbot.pull.messagesByType(opts), |
27 | pull.filter(msg => !blocking().includes(msg.value.author)) |
28 | ) |
29 | } |
30 | }) |
31 | } |
32 |
Built with git-ssb-web