git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: f6a49ebd9fb233e15e04deecd49ddcbc3f6a4857

Files: f6a49ebd9fb233e15e04deecd49ddcbc3f6a4857 / feed / pull / type.js

850 bytesRaw
1const nest = require('depnest')
2const extend = require('xtend')
3const pull = require('pull-stream')
4
5exports.gives = nest('feed.pull.type')
6exports.needs = nest({
7 'sbot.pull.messagesByType': 'first',
8 'contact.obs.blocking': 'first',
9 'keys.sync.id': 'first'
10})
11
12exports.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