git ssb

10+

Matt McKegg / patchwork



Tree: 13be5ee9906beb5d8c2a24db46c68ef183c78d3a

Files: 13be5ee9906beb5d8c2a24db46c68ef183c78d3a / modules / obs-recently-updated-feeds.js

836 bytesRaw
1var pull = require('pull-stream')
2var pullCat = require('pull-cat')
3var computed = require('@mmckegg/mutant/computed')
4var MutantPullReduce = require('../lib/mutant-pull-reduce')
5var plugs = require('patchbay/plugs')
6var sbot_log = plugs.first(exports.sbot_log = [])
7var hr = 60 * 60 * 1000
8
9exports.obs_recently_updated_feeds = function (limit) {
10 var stream = pull(
11 pullCat([
12 sbot_log({reverse: true, limit: limit || 500}),
13 sbot_log({old: false})
14 ])
15 )
16
17 var result = MutantPullReduce(stream, (result, msg) => {
18 if (msg.value.timestamp && Date.now() - msg.value.timestamp < 24 * hr) {
19 result.add(msg.value.author)
20 }
21 return result
22 }, {
23 startValue: new Set(),
24 nextTick: true
25 })
26
27 result.has = function (value) {
28 return computed(result, x => x.has(value))
29 }
30
31 return result
32}
33

Built with git-ssb-web