git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: afa56eb7571ee8dfe04b3c9df5b72266829b8296

Files: afa56eb7571ee8dfe04b3c9df5b72266829b8296 / feed / pull / private.js

940 bytesRaw
1const pull = require('pull-stream')
2const nest = require('depnest')
3const extend = require('xtend')
4
5exports.gives = nest('feed.pull.private')
6exports.needs = nest({
7 'sbot.pull.log': 'first',
8 'message.sync.unbox': 'first'
9})
10
11exports.create = function (api) {
12 return nest('feed.pull.private', function (opts) {
13 var opts = extend(opts)
14
15 // handle limit to ensure we're getting old private messages
16 var limit = opts.limit
17 delete opts.limit
18
19 var stream = pull(
20 api.sbot.pull.log(opts),
21 unbox()
22 )
23
24 if (limit) {
25 return pull(
26 stream,
27 pull.take(limit)
28 )
29 } else {
30 return stream
31 }
32 })
33
34 // scoped
35
36 function unbox () {
37 return pull(
38 pull.filter(function (msg) {
39 return typeof msg.value.content === 'string'
40 }),
41 pull.map(function (msg) {
42 return api.message.sync.unbox(msg)
43 }),
44 pull.filter(Boolean)
45 )
46 }
47}
48

Built with git-ssb-web